I use "scp" command in my shell script. How do I get the error log , if that command is not working.

This is how I am using it scp file username@servername:/specificdirectory/

link|improve this question

67% accept rate
feedback

3 Answers

up vote 2 down vote accepted

If you encounter an error while running scp, try doing ssh first to the server, scp doesn't have a graceful handling of new keys and ssh is more verbose with error reporting by default.

To get a more detailed log of what is happening, try running it with -v:

scp -v file username@servername:/specificdirectory/

You must also remember that path starting with / are absolute, not relative to your home directory, as such you may want to try:

scp file username@servername:specificdirectory/
link|improve this answer
I am using scp in a script , can i still use -v option and try to get the detail log in a log file? – yogsma Oct 5 '10 at 18:19
1  
-v writes debug information to STDERR. so if you redirect STDERR output to a log file then all debug info will be there. – Casual Coder Oct 5 '10 at 18:26
thanks, I am using that way now. – yogsma Oct 5 '10 at 19:13
feedback

A good way to get debug output with bash is to use set -x. Typically, any results will be output to STDOUT or STDERR. How that is captured will depend on how your script is being executed. As per the bash(1) manpage:

      -x      After  expanding each simple command, for command, case
              command, select command,  or  arithmetic  for  command,
              display the expanded value of PS4, followed by the com-
              mand and its  expanded  arguments  or  associated  word
              list.
link|improve this answer
feedback

Usually programs in unix environment writes errors to, well, standard error output. so you can execute your command like this:

scp -v file username@servername:/specificdirectory/ 2> scp_error.log   
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.