【发布时间】:2020-10-09 18:09:01
【问题描述】:
我试图通过运行命令并尝试在 shell 脚本变量中捕获结果来捕获活动进程的数量,但不幸的是,没有捕获任何内容。代码如下:
#!/bin/ksh
## Checking whether or not the Previous Build is Completed
count_build_status=`ps -ef | grep BDD_PreCheck.sh | grep -c FT_BGmgmt` | tee -a ${logFile}
echo "The Value of Count Build Status is $count_build_status"
if [[ "${count_build_status}" != "0" ]]
then
echo INFO - The previous build has not ended yet. Please Wait for some time or contact the Administrator | tee -a $logFile
exit 1;
fi
exit 0;
这里,ps -ef | grep BDD_PreCheck.sh | grep -c FT_BGmgmt 如果单独执行,结果为 0,但 'count_build_status' 中存储的值为 null。
谁能帮忙?
【问题讨论】:
-
bash 不是 ksh。
标签: bash shell variables unix sh