Skip to content

Exit codes

This tool supports standard exit codes to indicate the success or failure of an operation.

  • On success (e.g., a file is uploaded successfully), the application will return an exit code of 0.
Terminal window
$ connect send sftp -h 10.0.0.24 -l monitor01 -p password --file file1.zip
2025/06/24 09:08:22 INFO Sending files to sftp://[email protected]:
2025/06/24 09:08:22 INFO Files to send: count=1
[file1.zip] 10.00 MiB / 10.00 MiB done
$ echo $?
0
  • On failure, the application will return a non-zero exit code, indicating that an error occurred.
Terminal window
$ connect send sftp -h 10.0.0.24 -l monitor01 -p password --file file1.zip --batch
2025/06/24 09:08:41 INFO Sending files to sftp://[email protected]:
2025/06/24 09:08:41 INFO Files to send: count=1
2025/06/24 09:09:11 ERROR Error while getting sftp session error=dial tcp 10.0.0.24:22: i/o timeout file=file1.zip
$ echo $?
1

This behavior makes it easy to integrate the tool into custom scripts or automation workflows, where exit codes can be used to programmatically detect and handle errors.

Example usage in a shell script:

#!/bin/bash
connect send sftp -h 10.0.0.24 -l monitor01 -p password --file file1.zip
if [ $? -eq 0 ]; then
echo "Upload successful"
else
echo "Upload failed"
fi