LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Exit status of SFTP (https://www.linuxquestions.org/questions/programming-9/exit-status-of-sftp-738233/)

solar05 07-07-2009 02:03 AM

Exit status of SFTP
 
Hello to everybody.
I copy files from host to host via sftp.
Sometimes connection via hosts may be down.

When SFTP copy files to remote host and connection breaked
SFTP session hung... And script also hung. How I can see it? And break the session?

unSpawn 07-07-2009 06:21 AM

Quote:

Originally Posted by solar05 (Post 3599351)
How I can see it?

SFTP allows you to use some SSH options like ConnectionAttempts, ConnectTimeout, LogLevel, ServerAliveInterval, ServerAliveCountMax. So by monitoring (verbose?) process output you might be able to grep for problems or stalling.


Quote:

Originally Posted by solar05 (Post 3599351)
And break the session?

A crude way could be to use a timer that starts when the SFTP transfer starts and watches for changes in (verbose) transfer output. If nothing changes in n minutes you could conclude the transfer stalled (or was broken off reading exit status "$?") and kill the transfer PID.

solar05 07-07-2009 07:43 AM

Quote:

Originally Posted by unSpawn (Post 3599551)
SFTP allows you to use some SSH options like ConnectionAttempts, ConnectTimeout, LogLevel, ServerAliveInterval, ServerAliveCountMax. So by monitoring (verbose?) process output you might be able to grep for problems or stalling.



A crude way could be to use a timer that starts when the SFTP transfer starts and watches for changes in (verbose) transfer output. If nothing changes in n minutes you could conclude the transfer stalled (or was broken off reading exit status "$?") and kill the transfer PID.

On Solaris this options don't exist ConnectionAttempts, ConnectTimeout, LogLevel, ServerAliveInterval, ServerAliveCountMax...


All times are GMT -5. The time now is 08:37 PM.