?
Solved

Copy file (cp) from one command line (BSD) to another.

Posted on 2010-09-12
6
Medium Priority
?
452 Views
Last Modified: 2012-06-27
logged in via ssh, need to copy a file from another machine back to my machine.
What is the command for the extraction of the file.
I know how to cp a file from directory to directory or mv, can't remember the command.
Unix.
0
Comment
Question by:T_Myles
6 Comments
 
LVL 6

Expert Comment

by:sagiamar
ID: 33658127
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33658157
scp /source/file user@targethost:/target/directory/
or
scp user@sourcehost:/source/file /target/directory/
0
 

Author Comment

by:T_Myles
ID: 33658545
woolmilkporc:

I'm in the machine via ssh I want to send file to another remote server.
A directory is what I want to cp over.

Since I'm inside the machine, shouldn't there be a -R included, I'm confused about the second line.
If I can rap my head around the path I can get it.  
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
LVL 2

Expert Comment

by:anoym
ID: 33658625
To copy files and subdirectories I'm using:

# scp -r -p /source_directory/* username@ip_adresse:/target_directory

To copy a whole directory you can use:

# scp -r -p /source_directory username@ip_adresse:/target_directory

and pls check:

http://amath.colorado.edu/computing/software/man/scp.html

0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 33660113
My first line is for copying a file /source/file from the machine you're logged in to a remote server named targethost as user user into the directory /target/directory there.
My second line is for copying a file /source/file from a remote server named sourcehost as user user into the local directory /target/directory
By the way, with scp you can even copy a file/files from one remote machine to another remote machine while being logged in via ssh to a third, arbitrary machine, and moreover, you can give it a new name (the italic string in angle brackets (  <... > ) is meant to indicate the shell prompt!)
<user0@somehost0> ssh user1@somehost1  # (or via PuTTY, or whatever)
<user1@somehost1> (Logged in)
<user1@somehost1> scp user2@somehost2:/source/file user3@somehost3:/target/directory/new_filename
<user1@somehost1> exit
<user0@somehost0>
 
All of the above is for files, since in your question you asked for copying a file.
There is no "-R" (uppercase R) for scp. To have scp work recursively use the "-r" (lowercase r) flag, as indicated by anonym.
wmp
0
 

Author Closing Comment

by:T_Myles
ID: 33662943
Thanks for the detail explanation.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Hello to you all, I hear of many people congratulate AWS (Amazon Web Services) on how easy it is to spin up and create new EC2 (Elastic Compute Cloud) instances, but then fail and struggle to connect to them using simple tools such as SSH (Secure…
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 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