bash – 两个相同的功能,但一个挂起
发布时间:2020-12-15 21:07:09 所属栏目:安全 来源:网络整理
导读:我无法解释为什么其中一个函数可以正常运行[status-up],但另一个函数根本就没有输出. [状态-REC] pidfile和recfile都是/ var / run /中各自PID文件的有效路径,两者都只包含一个没有换行符的PID号或其他不可打印的字符. status-up() { if [ -f ${pidfile} ];
我无法解释为什么其中一个函数可以正常运行[status-up],但另一个函数根本就没有输出. [状态-REC]
pidfile和recfile都是/ var / run /中各自PID文件的有效路径,两者都只包含一个没有换行符的PID号或其他不可打印的字符. status-up() { if [ -f ${pidfile} ]; then if ps p $(cat ${pidfile}) >> /dev/null; then printf "Upload running as PID %sn" $(cat ${pidfile}) return fi fi echo "Upload is not running" } status-rec() { if [ -f ${recfile} ]; then if ps p $(cat ${recfile}) >> /dev/null; then printf "Receive running as PID %sn" $(cat ${recfile}) return fi fi echo "Receive is not running" } 解决方法
如果没有给出任何输入,猫会挂起 – 以及许多其他程序.你的一条路径很可能是空的,因为你可以通过if语句:
$if [ -f ]; then echo "foo"; fi foo 进入区块后,您将挂在通话猫< empty>上.正如@ruakh指出的那样,你应该让它工作双引变量. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |