ZKX's LAB

怎么将shell脚本放入后台执行 shell结束脚本命令

2021-04-27知识7

linux中设计一个shell脚本程序可以接受命令行输入的参数执行相应的菜单命令 之所以用到命令行参数,关键在于shell脚本需要与运行脚本的人员进行交互。。

在c\\c++程序里怎么执行shell脚本命令? 在C/C++源码中执行shell命令,最基本的就是 system()C库函数,其次可以使用系统提供的api函数,比如windows上的createprocess shellexecuteex等函数,在linux上可以使用exec()等等.下面是我在windows上的弄的一个测试版本,使用了线程,我感觉用nc来测试,不如直接 netstat-an|findstr/I\"udp\"|findstr\"22\",因为22端口太其特了,很容易抓出来.另外nc判断端口常规的作法就是 nc-vv ip port 看提示信息就好了.includeincludeincludeincludeincludeUINT_stdcall ThreadFunc(LPVOID lpParam){将hacker字符串做为nc提交的数据int ret=system(\"echo hacker|nc.exe-u 127.1 22\");ret=0说明没有开启22端口if(ret=0)printf(\"nc:Write error:Connection refused.\\n\");return 0;}int main(){HANDLE hThread=(HANDLE)_beginthreadex(0,0,ThreadFunc,0,0,0);等待3秒钟,说明22端口可用WaitForSingleObject(hThread,3000);结束测试线程TerminateThread(hThread,0);重新开启NC连接22端口system(\"nc.exe-vv-u 127.1 22\");return 0;}欢迎光临0x30贴吧,一个高质量的计算机技术交流平台.

linux shell 脚本运行完毕后不能自动停止 最简单方法:其实,你按2113一下回车就可5261以知道是否\"结束\"了吧?更好的办法4102:你在done后面加多两行1653:代码开始-waitecho\"All is okexit 0代码结束-参考资料:wait 命令http://book.51cto.com/art/201205/338877.htm

#shell脚本基本命令#shell结束脚本命令#shell脚本传入命令#shell脚本打包命令

随机阅读

qrcode
访问手机版