2

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/

3 Answers 3

3

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/
2
  • 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, 2010 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. Oct 5, 2010 at 18:26
1

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.
1

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   

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .