Options:
-l listen mode,for inbound connects
-p PORT local port number
-i SECS delay interval for lines sent
-e PROG program to exec after connect (dangerous!)
-w SECS timeout for connects and final net reads
而在Asianux 3.0 SP1系统中提供的nc版本则是1.84的,按上面的参数用法写会执行不了:
引用[root@ftpserver ~]# rpm -q nc
nc-1.84-10
[root@ftpserver ~]# nc -lp 1234
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]
[-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]
[-x proxy_address[:port]] [hostname] [port[s]]
讲查看man文档,可见在这个版本中,-l是不能与-s、-p、-z一起使用的,-w参数也会被忽略,所以,正确的用法是:
[root@ftpserver tmp]# nc -l 1234
四、用在脚本中
nc每次启动监听后,都会在客户端连接完成并退出的同时,服务端一同退出。所以,如果需要不断的使用nc进行数据传输,需要在脚本中使用循环。利用nc实现更多的功能,可参考其rpm提供的参考脚本:
引用# rpm -qd nc
/usr/share/doc/nc-1.10/Changelog
/usr/share/doc/nc-1.10/README
/usr/share/doc/nc-1.10/scripts/README
/usr/share/doc/nc-1.10/scripts/alta
/usr/share/doc/nc-1.10/scripts/bsh
/usr/share/doc/nc-1.10/scripts/dist.sh
/usr/share/doc/nc-1.10/scripts/irc
/usr/share/doc/nc-1.10/scripts/iscan
/usr/share/doc/nc-1.10/scripts/ncp
/usr/share/doc/nc-1.10/scripts/probe
/usr/share/doc/nc-1.10/scripts/web
/usr/share/doc/nc-1.10/scripts/webrelay
/usr/share/doc/nc-1.10/scripts/websearch
/usr/share/man/man1/nc.1.gz
(编辑:ASP站长网)
|