LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-05-2012, 02:58 PM   #1
lailai
LQ Newbie
 
Registered: Mar 2012
Posts: 1

Rep: Reputation: Disabled
scp shortcut for multiple files


Hello guys,

i am pretty new to linux and shell, currently, i am trying to use scp command to transfer files between my computer with a remote server.
every time i type like:

scp user@remote_server.com:/dir/file_1 .
scp user@remote_server.com:/dir/file_2 .
....
scp user@remote_server.com:/dir/file_n .

then i write a script file called 'getr' and put into my /bin directory, the getr looks like
scp user@remote_server.com:$1 .

now i only need to type 'getr /dir/file_1' and 'getr /dir/file_2' to fetch the files from the remote server.
if the files i needed have similar naming rules, i can use the regular expression like 'getr /dir/file_*' to
get the files by only one command, however, for many cases, files i need to fetch have quite different names, like two files with the name 'aaa.txt' and '123455_uyt',
so my question is
is there anyway a way to send the names of wanted files as arguments to some more advanced version of the currently 'getr', so that for several files with quite different names, i can also fetch them by one command?

thank you guys in advance.
 
Old 03-05-2012, 04:02 PM   #2
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,564

Rep: Reputation: 112Reputation: 112
Look for these applications in your distro's repository:

dsh
mssh
mussh
pssh
taktuk

One of them should be useful to you.

DSH, for example, can be found here:
http://www.netfort.gr.jp/~dancer/software/dsh.html
 
Old 03-05-2012, 05:38 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by lailai
is there anyway a way to send the names of wanted files as arguments to some more advanced version of the currently 'getr', so that for several files with quite different names, i can also fetch them by one command?
Some other ideas as well...

----------

Simple adjustment to the shell script.
Code:
#!/bin/bash

# If anyone other than you is going to be using this,
# you'll want to validate input data. Note that this
# may break if file names have spaces in them.

if [ $# -eq 0 ] ; then

  echo "Usage: $0 file_1 file_2 file_3 file_n"
  exit 1

fi

for I in "$@" ; do

  echo "Downloading $I"
  scp foo@myhost.local:/dir/$I .

done

exit 0
----------

Or look into using rsync(1), if it makes sense for your circumstances. Then you won't have to worry about feeding filenames to a script.

Last edited by anomie; 03-05-2012 at 05:40 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp - multiple files at once rpd25 Linux - Newbie 3 01-30-2012 01:47 AM
scp file to multiple hosts with expect loadedmind Programming 4 04-11-2011 09:28 PM
Keyboard Shortcut to switch between multiple monitors FractalTheorem Linux - General 2 03-08-2009 09:06 PM
scp for multiple cilents?? mlu Linux - Networking 1 05-25-2005 09:44 AM
Spawning multiple scp using different I/F sam0murphy Solaris / OpenSolaris 1 05-18-2005 08:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration