【发布时间】:2018-12-28 09:02:07
【问题描述】:
我正在尝试运行一个基本上运行 psg defunct | wc -l 的脚本,并根据其输出是否大于或等于 1 来提供输出。
但是,我无法让-ge 标志起作用。我想知道是否有人对我做错了什么有任何意见,如果你能帮助我纠正它。
这是当前脚本:
#!/bin/bash -x
export LANG="C"
#
# Created by Blake Smreker | b0s00dg
# Purpose is to assist users with defunct process tickets
#
#
menu ()
{
echo "What is the server name?"
read srvrname
badboi=$"$srvrname"
}
vars ()
{
psgwc=$"/u/bin/psg defunct | wc -l"
psgd=$"/u/bin/psg defunct"
die=$"/bin/kill -9 `psg defunct | awk '{print $3}'`"
belowmsg=$'echo The number of defunct processes is below threshold! Resolve the ticket and put the following in the ticket:'
abovemsg=$'echo There is more than 100 zombies! Getting you more information:'
}
connect ()
{
connectme="/usr/bin/dzdo -u oseho /bin/ssh -qo PreferredAuthentications=publickey root@$badboi"
}
main ()
{
${connectme} ". /u/data/environment; $psgwc"
if ${connectme} $psgwc -ge 1
then
$abovemsg
echo "Determine the owner of the below process. Then copy and paste the below, and send it to the team on Service Now."
echo "psg defunct | wc -l:"
${connectme} $psgwc
${connectme} $psgd
else
$belowmsg
echo "psg defunct | wc -l:"
${connectme} $psgwc
fi
}
menu
vars
connect
main
这是错误信息:
+ /usr/bin/dzdo -u oseho /bin/ssh -qo PreferredAuthentications=publickey root@oses4101 /u/bin/psg defunct '|' wc -l -ge 1
wc: illegal option -- g
usage: wc [-c | -m | -C] [-lw] [file ...]
似乎认为我使用-ge 是我使用wc 的一部分。但是,当我尝试纠正它时,它不起作用。
问题在于底部的 if 语句。
【问题讨论】:
标签: linux bash shell unix scripting