?
Solved

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

Posted on 2010-09-12
6
Medium Priority
?
449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

649 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