[英]Using system(“command”) in Linux
Is it recommended to call shell commands from a C program in C using system() ? 是否建议使用system()从C语言中的C程序调用shell命令?
I want to develop a web crawler in C and want to use wget to fetch content from a URL ? 我想在C中开发一个Web爬虫,并希望使用wget从URL获取内容? Should I do it using system(" wget ...") ?
我应该使用系统(“wget ...”)吗?
Regardless of the programming language, calling system shell should really be the last resort when nothing else works, because: 无论使用何种编程语言,调用系统shell都应该是最后的选择,因为:
The same wget
was a problem for us when we were porting some nasty perl code to mobile device. 当我们将一些讨厌的perl代码移植到移动设备时,同样的
wget
对我们来说是一个问题。 While just from Linux to Linux, we discovered that "standard" wget
has some switches BusyBox does not support so needed to port wget
as well, and later even grep
as if perl would not have its own pattern search. 虽然从Linux到Linux,我们发现“标准”
wget
有一些交换机BusyBox不支持端口wget
也需要,后来甚至grep
就好像perl不会有自己的模式搜索。 After that I am fully convinced that better no. 在那之后,我完全相信更好的没有。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.