I have a need to move my log files around and I am using a simple perl scp script to do this. Now I need to add some error reporting to the script and I am in over my head.
1: I need to send an email when scp cannot connect to a server
2: I need to send and email if scp cannot find the file to download
How can I get the error codes on a failure and what do I do with it?
Please help me out if you can, I've been searching the web with no luck for 2 days.
currently my scp command looks something like this:
GET THE FILE WITH SCP
#
$filetoget="$LOGFILEDIR/$f\.@FILEDOMAIN\$i\.$year-$mon-$mday";
$command = "/usr/bin/scp $a:$filetoget $f\.@FILEDOMAIN\$i\.$year$mon$mday\.$a";
try testing and/or outputting the $! variable and see what you get.
you can print it in numeric or string context to see either the error number or the error string.
$? you need to check ... scp exits with 0 on success or >0 if an error occurred.
These are the only ones I was able to find:
1: General error in file copy
2: Destination is not directory, but it should be
3: Maximum symlink level exceeded
4: Connecting to host failed
5: Conneciton broken
6: File does not exist
7: No permission to access file
8: General error in sftp protocol
9: File transfer protocol mismatch
10: No file matches a given critera
65: Host not allowed to connect
66: General error in ssh protocol
67: Key exchange failed
68: Reserved
69: MAC error
70: Compression error
71: Service not available
72: Protocol version no supported
73: Host key not verifiable
74: Connection failed
75: Disconnected by application
76: Too many connections
77: Authentication cancelled by user
78: No more authentication methods available
79: Invalid user name