我的shell脚本中的lsof命令无法正常工作,但在Terminal中可以正常工作。我已经设置了lsof命令的完整路径,但是总是抛出关于此的错误:
lsof: unacceptable port specification in: -i :
lsof 4.89
latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
usage: [-?abhlnNoOPRtUvV] [+|-c c] [+|-d s] [+D D] [+|-f[cgG]]
[-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+|-M] [-o [o]] [-p s]
[+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Use the ``-h'' option to get more help information.
function launchAnyproxy()
{
cd ../..
port=`/usr/sbin/lsof -t -i :8888`
echo $port
#port=`netstat -ln |grep '8888'`
if [ ! -n "$port" ]; then
anyproxy --intercept
else
echo "8888 is listening by other process"
fi
}
launchAnyproxy