nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

remote login and copy files over ssh

This is a discussion on remote login and copy files over ssh within the Shell scripting forums, part of the Development/Scripting category; Hi, One of my linux machine create somefiles over web. I want a script to copy the same file on ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 30-11-2009, 06:00 PM
Senior Member
User
 
Join Date: Jul 2006
Posts: 145
Thanks: 0
Thanked 2 Times in 2 Posts
Rep Power: 4
asim.mcp is on a distinguished road
Default remote login and copy files over ssh

Hi,

One of my linux machine create somefiles over web. I want a script to copy the same file on remote computer using ssh and scp.

when i run
PHP Code:

prompt
ssh login@server1 cd /path/to/dir/ ; scp filename login@server2:/root/backupdir
nothing happen. Any help please????


Regards

Last edited by asim.mcp; 30-11-2009 at 06:15 PM.
Reply With Quote
  #2 (permalink)  
Old 30-11-2009, 06:30 PM
Senior Member
User
 
Join Date: Jul 2006
Posts: 145
Thanks: 0
Thanked 2 Times in 2 Posts
Rep Power: 4
asim.mcp is on a distinguished road
Default

Hi,

I've get the solution...

PHP Code:

ssh login
@server1 "cd /path/to/dir ; scp file.name login@server2:/path/to/dir" 

The above command work for me.
Reply With Quote
  #3 (permalink)  
Old 02-12-2009, 01:02 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Short and simple (no need to run ssh):

Code:
scp user@server1:/path/to/file   user@server2:/path/to/dest
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply

Tags
linux , openssh , scp , ssh


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Script To Copy Files From Windows XP To Linux Server haykins Shell scripting 6 18-09-2009 12:12 PM
Check if remote files exist (periodically) pixelboss Shell scripting 2 28-02-2009 11:08 AM
How to copy and paste files in FreeBSD enochalbert All about FreeBSD/OpenBSD/NetBSD 1 01-09-2008 07:12 PM
Script to delete a set of files in Remote machine ashok333 Shell scripting 4 09-05-2008 07:24 PM
How to copy . files from current directory ricc Linux software 1 10-06-2006 09:23 PM


All times are GMT +5.5. The time now is 02:20 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38