Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash脚本upd错误_Bash - Fatal编程技术网

Bash脚本upd错误

Bash脚本upd错误,bash,Bash,我执行bash脚本PLCCheck作为进程 ./PLCCheck & PLCCheck SQLCheck 端口6001和4001在iptables中打开,两个脚本作为一个进程工作。为什么会出现此错误?我已检查了nc的手册页。我认为它的使用方式是错误的: -l Used to specify that nc should listen for an incoming connection rather than initiate a connection t

我执行bash脚本PLCCheck作为进程

./PLCCheck &
PLCCheck

SQLCheck


端口6001和4001在iptables中打开,两个脚本作为一个进程工作。为什么会出现此错误?

我已检查了nc的手册页。我认为它的使用方式是错误的:

 -l      Used to specify that nc should listen for an incoming connection rather
         than initiate a connection to a remote host.  It is an error to use this
         option in conjunction with the -p, -s, or -z options.  Additionally,
         any timeouts specified with the -w option are ignored.

根据这一点,不应该使用-l选项和-p选项


试着不用-p,只用nc-l4001。也许这就是错误…

Hmmm。。。两者都使用默认端口6002,但我看不到在PCLCheck脚本中如何使用该端口。也许它们会相撞…对不起。同样的方法是netcat-u-c$主机$端口。PLCCheck每5分钟发送一次。SQLCheck每120-300分钟随机发送一次。尝试在两个脚本的开头使用set-x,并在两个终端中作为前台进程启动它们,以找出此错误消息出现在哪一行。根据你的部分脚本,它可以在任何一行…我明白了。条形码阅读器有问题。所以我无法监听端口4001。谢谢你们!六羟甲基三聚氰胺六甲醚。。。那么脚本怎么能像你提到的那样单独工作呢?@Philipp88:-l是必需的,而-p是不需要的。@Philipp88:Hmm。根据你的部分脚本很难猜测,但同时使用这些选项肯定是错误的。@Philipp88:I浏览了一点,这似乎只是根据RedHat Linux手册页判断的错误。如果使用不同的nc分布,这可能是正常的。
./SQLCheck &
while read -r line 
do 
   ... 
   def_host=192.168.100.110 
   def_port=6002
   HOST=${2:-$def_host}
   PORT=${3:-$def_port} 

   echo -n "OPENEF1" | netcat -u -c $HOST $PORT 
done < <(nc -l -p 4001)
Error: Couldn't setup listening socket (err=-3)
 -l      Used to specify that nc should listen for an incoming connection rather
         than initiate a connection to a remote host.  It is an error to use this
         option in conjunction with the -p, -s, or -z options.  Additionally,
         any timeouts specified with the -w option are ignored.
 -p source_port
         Specifies the source port nc should use, subject to privilege restrictions
         and availability.  It is an error to use this option in conjunction with the
         -l option.