NYCPHP Meetup

NYPHP.org

[nycphp-talk] [OT] scp exit codes?

Hans Zaunere hans at nyphp.com
Wed Sep 22 08:00:58 EDT 2004


> I know this is kinda off-topic; I googled around but didn't know the
> appropriate place to post this. Suggesstions are welcome.
> 
> I am using PHP's system() call (am I now on-topic?) to capture the
exit code

Technical discussion regarding PHP and open source - on topic.
Talking about Gmail's front-end architecture on NYPHP-Front End - on
topic.

Gmail Invites - worthless.

(sorry for the MasterCard parody)

> of scp. I have a machine called 'downhost' that is currently offline;
I want
> to test the failure of scp.
> 
> host 1:
> FreeBSD 4.8-RELEASE-p20
> OpenSSH_3.5p1 FreeBSD-20030924
> 
> 
> command 1: copy a file from host1 (local) to downhost:
> -----------------------------------------------
> scp -i /etc/ssh/ssh_host_dsa_key /home/user/file.xml
user at downhost:file.xml
> ; echo $?
> -----------------------------------------------
> echoing the exit code properly gives me a '1', because the target host
> cannot be reached.
> 
> 
> 
> command 2: copy a file from  host1 (local) to another location on
host1
> (local):
> -----------------------------------------------
> scp -i /etc/ssh/ssh_host_dsa_key /home/user/file.xml
/home/user/file2.xml;
> echo $?
> -----------------------------------------------
> echoing the exit code properly gives me a zero; it was successfully
copied.
> 
> 
> 
> command 3: copy from webdmz to  host1 (local):
> -----------------------------------------------
> scp -i /etc/ssh/ssh_host_dsa_key user at downhost:file.xml
/home/user/file.xml
> ; echo $?
> -----------------------------------------------
> echos zero!! This is strange since downhost cannot be found!!
> 
> 
> Huh! I was hoping command 3 would exit with non-zero... Am i thinking
about
> this wrong?

I think you're on track.  Since the man page says:

scp exits with 0 on success or >0 if an error occurred.

This must be a bug.  Try an absolute path for the source file, but I
doubt that makes a difference.

H



More information about the talk mailing list