RE: sftp exit codes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



First of all, thanks to everyone who replied with a tip or suggestion. I
appreciate the help.

My answer seems to have been straight forward and I guess I should have just
looked at the source (sftp.c):

int
main(int argc, char **argv)
{
	...

	exit(err == 0 ? 0 : 1);
}

So, just as JReed said, it's 0 or 1. The best I can do for now is to see if
I get '1' and report that there was some sort of error condition.

> -----Original Message-----
> From: Jeremy C. Reed [mailto:reed@xxxxxxxxxxxxx]
> Sent: Monday, April 28, 2008 5:57 PM
> To: Bond Masuda
> Cc: secureshell@xxxxxxxxxxxxxxxxx
> Subject: Re: sftp exit codes?
> 
> Just 1 or 0.
> 
> See sftp.c (and sftp-client.c).
> http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/
>
>   Jeremy C. Reed

Thanks for pointing me directly at what I should have just looked at.

> -----Original Message-----
> From: Sharad [mailto:sharad2011@xxxxxxxxx]
> Sent: Monday, April 28, 2008 11:40 PM
> To: Bond Masuda; secureshell@xxxxxxxxxxxxxxxxx
> Subject: Re: sftp exit codes?
> 
> Hello Bond,
> 
> I am not certain how you will handle sftp - which
> happens to be interactive by nature; in a shell
> script.
> 
> I am using scp along with BatchMode on command line.
> This will not prompt for password. If authentication
> is configured to work without password, the scp will
> do it's job. If scp fails for any reason, like keys
> not established, then you can capture the return code
> and do necessary action.
> 
> Regards,
> Sharad
> p.s. - this is not a direct answer to your query but
> another option to explore. I think scp will be a
> better choice over sftp.

Thank you for the suggestion. I was originally going to just use scp, as
it's a bit easier to script around. Unfortunately, the OpenSSH
implementation of scp and the SSH Communication's version of scp don't seem
to work together. (OpenSSH scp causes the SSH communication's sshd to start
some non-existent child process) sftp was the only method that seemed to
work in this situation. Fortunately, sftp does have a 'batchmode' as well so
I can use that.

> -----Original Message-----
> From: Michel Chamberland [mailto:mercjr@xxxxxxxxx]
> Sent: Tuesday, April 29, 2008 9:50 AM
> To: Bond Masuda
> Cc: secureshell@xxxxxxxxxxxxxxxxx
> Subject: Re: sftp exit codes?
> 
> not sure if it's an option for you but newer curl and libcurl work
> pretty well with both sftp and ftps.
> 
> lots of return codes with meaningful descriptions...

That's good to know, I wasn't aware of the recent updates in curl.
Unfortunately, not a practical option in my current project. They have
"restrictions" on using FOSS tools, and getting them to "approve" OpenSSH
only came about when all other options were exhausted.

As it stands, I best that can be done now is to see if I get a exit code of
1, and perhaps parse the sftp output to find the error.

Thanks again for all the suggestions and help. I think I know what I need to
do now...
-Bond



[Index of Archives]     [Open SSH Unix Development]     [Fedora Users]     [Fedora Desktop]     [Yosemite Backpacking]     [KDE Users]     [Gnome Users]

  Powered by Linux