How can we get and handle the sftp return codes in a C program if sftp fails to put the file in a server?
We need to transfer the files again if sftp fails to put it in the sftp server.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you want to use the command line sftp from within a C program, this program illustrates one way to do it (it’s rather ugly but shows the idea):
Use
man system, and thenman 2 waitfor info on WEXITSTATUS macro.The value of ret is the return code of sftp and can be used to determine failure in sftp and decide what to do next.