我试图通过curl上传一个文件,作为shell脚本的一部分,并试图根据进度表确定tftp是否成功。有什么建议吗?
curl --upload-file <filename> tftp://<tftp>
发布于 2014-06-16 14:00:45
您可以使用以下方法重定向命令的输出
curl --upload-file tftp:// 2> file
2>
将stderr输出重定向到文件。
如果使用的是(bash) shell脚本,则应该使用退出值。如果成功,curl的退出值应为0。例如:
#/bin/bash
# Upload file
curl --upload-file tftp://....;
# Store the exit value, since it will be lost after the next command
exitvalue=$?;
# Check if the exit value equals 0
if [[ $exitvalue -eq 0 ]]; then
echo "Download succeeded!";
else
echo "Download failed, exit value $exitvalue";
fi
https://stackoverflow.com/questions/24252804
复制相似问题