Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you know if scp is successful? 1

Status
Not open for further replies.

jeffchel

MIS
Sep 13, 1999
4
US
I can run scp -p one.txt user@server:/one.txt and the output will show one.txt along with 100%. If I add this same command in a script, I cannot get it to show the 100%. I have tried 1>/tmp/one.out 2>/tmp/two.out but neither one contains this line. I have also tried running it with -v (or -v -v or -v -v -v). That gives more information, but not the line I want. I have also not been able to find a listing of error codes for scp (I know anything other than zero is an error). Anyone have any ideas how to get it to capture the 100% line?
 
first, the -P and not (-p) shoud be followed by a port number, to be used if SSHD on the receiving PC is not running on port 22.

for the redirection, have you tried &> yourfilelog

CHeers

QatQat

Life is what happens when you are making other plans.
 
I tried your suggestion of &>yourfilelog and it still did not give me the line with the filename and 100% (or any percent). Thanks for the suggestion though.
 
why not use the -B for batch mode and then test the result.
if [ $? <> 0 ] then an error occurred.
 
This should work from within a script:

scp <rest of scp options and file(s) to copy>
if [ $? -eq 0 ]
then
echo "Success"
else
echo "scp failed"
fi


Modify as needed for the script - but that should be enough to tell whether it was successful or not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top