NYCPHP Meetup

NYPHP.org

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

Fan, Wellington wfan at VillageVoice.com
Tue Sep 21 13:30:51 EDT 2004


Folks,

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
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?


TIA,
Wellington




More information about the talk mailing list