Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi folks,
I want to copy the file from remote server to my system for that i had written the shell script
scp user@ip source destination
it is working fine
but now i had to copy the file from two different file locations in the remote machine
for that i had written the two times
scp user@ip source destination
scp user@ip source1 destination1
but what is happening that it is creating the file not copying the content of the file
it is just copying the content of the first file itself only
for that i had written the two times
scp user@ip source destination
scp user@ip source1 destination1
Welcome. "scp" needs to have the user and hostname associated with the path+file name to know which machine to copy to or from. So what you probably mean is either this to copy from remote to local:
"scp" is good if you want to copy the whole file each and every time. If you have a file that updates but otherwise stays the same, then "rsync" over SSH is a better choice.
Thanks for the reply
actually i had created a shell script in i had used
spawn scp copying command
in that i had to copy two files from two different folders so i had written two time scp command for copying the files what is happening that first file it is copying but in case of second file one file is created but it is empty file no conent is present in it.
As I always say, you can add "set -xv" to your script to enable verbose debugging for the script. You should run it from a terminal/command line (those are just different terms to describe the same thing, sorry many people question what the meaning of those are sometimes, you likely know this already, no offense intended). Within the command line you'll see the verbose output of each action for your script, plus you'll see any errors generated.
Please make sure that the second file exists on the system it is being copied from and that the file has content in it. I think you have indicated that you feel this is true. I'd recommend you try this with yet a third file. Please also verify that the second file is not a directory, there is a -r flag to use with scp to recurse into directories. Perhaps also this is permissions. Does the scp user have permissions to read files from that other directory?
Can you post your exact script, minus any sensitive parts? From what you first posted above, the syntax you are trying to use for "scp" is not quite right and it would be helpful to see exactly what you have.
here i am trying to automate the process of copying so using expect and send command for it
mk_prod.out is getting copied but not access.log
for checking purpose i had also verified it by placing acess.log at first at that time access.log is also getting copied
only the file which at the top is getting copied only
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.