Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Issue with scp, ssh and files types

Posted on 2014-11-27
4
Medium Priority
?
265 Views
Last Modified: 2014-11-28
Hi Experts, I'm doing:
ssh user@remote_IP find remote_path -name Transfer_data. * -maxdepth 1 perm perm -444 / 222! -perm / 111 -type f> TEMP_GIS / lista.lst

Open in new window

then on "TEMP_GIS / lista.lst" I have:
remote_path/Transfer_data.20141119172332
/remote_path/Transfer_data.20141119172032
/remote_path/Transfer_data.20141127120302
/remote_path/Transfer_data.20141127120232
/remote_path/Transfer_data.20141126165232
/remote_path/Transfer_data.20141126165203
/remote_path/Transfer_data.20141127115632
/remote_path/Transfer_data.20141127112703

Open in new window

this is almost correct, but how do I copy these files using scp -p command to another local directory, called INPUTS_GIS?

And I need in lista.lst:
Transfer_data.20141119172032
Transfer_data.20141127120302
Transfer_data.20141127120232
Transfer_data.20141126165232
Transfer_data.20141126165203
Transfer_data.20141127115632

Open in new window

Sorry if the question is very basic, but I need to resolve it as quickly as possible.
Thank you very much
Regards
0
Comment
Question by:carlino70
  • 2
4 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 40469513
To make "lista.lst" contain just the filenames you can do:

ssh user@remote_IP find remote_path ... ... ... -type f |xargs -I{} basename {} > TEMP_GIS/lista.lst

Open in new window


"... ..." stands for the rest of the find command (i didn't want to type all that).

Please explain what you mean with "copy to another local directory"!

Do you mean "copy the files listed in "lista.lst" from the remote server to the local machine"?

If so, you could do:

xargs -I{} scp user@remote_IP:/source/path/{}   /INPUTS_GIS/ < TEMP_GIS/lista.lst

Open in new window


"/source/path/ is the path on "remote_IP", probably "/remote_path".
0
 

Author Comment

by:carlino70
ID: 40469589
Excellent, you understood good!
I' ll try this.

Tkankyou
0
 
LVL 62

Expert Comment

by:gheist
ID: 40469691
basename command shows just file name minus path
0
 

Author Closing Comment

by:carlino70
ID: 40470463
It's work!
Thankyou again
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month9 days, 2 hours left to enroll

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question