获取退出状态code从“FTP”命令在Linux的shell
it1352
帮助1人
问题说明
我需要从一个命令行程序retrive退出状态code。不用担心,我用$?
但对于FTP,即使不连接,它打开ftp的外壳,所以我不能够理解的连接都不会发生。
I need to retrive the exit status code from a command line program. No worries, I used $?. But for ftp, even if it doesn't connect, it opens the ftp shell, so I'm not able to understand that the connection haven't take place.
试试这个code表示理解:
Try this code for understand:
#!/bin/sh
ftp 1234567
OUT=$?
if [ $OUT -eq 0 ];then
echo "ftp OK"
else
echo "ftp Error: "$OUT
fi
exit 0
任何帮助吗?
感谢菲利普
Any help? Thanks Filippo
正确答案
#1
您应该寻找从ftp命令,而不是寻找一个状态成功消息。这是226传输完成。您可以与您的系统上FTP的手动确认。
You should be looking for success message from ftp command rather than looking for a status. It's "226 Transfer complete". You can confirm it with ftp manual on your system.
200 PORT command successful.
150 Opening ASCII mode data connection for filename.
226 Transfer complete.
189 bytes sent in 0.145 seconds (0.8078 Kbytes/s)
下面是一个示例脚本。
FTPLOG=/temp/ftplogfile
ftp -inv <<! > $FTPLOG
open server
user ftp pwd
put filename
close
quit
!
FTP_SUCCESS_MSG="226 Transfer complete"
if fgrep "$FTP_SUCCESS_MSG" $FTPLOG ;then
echo "ftp OK"
else
echo "ftp Error: "$OUT
fi
exit 0
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcficki
系列文章
更多
同类精品
更多
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20