开发者

How to pass arguments to a bash script in my c program via popen()?

In my c progr开发者_StackOverflow社区am, I want to launch a script by popen().

like this: char mimetype[256];

//give mimetype a value

popen("xdg-mime query default some-mime-type", "r");

Is it possible to pass "some-mime-type" as an argument from c program to the bash command?

Great thanks!

Amanda


Sure:

char cmd[1024]

snprintf(cmd, sizeof(cmd), "xdg-mime query default %s", somemime_variable);
popen(cmd, "r");


It seems no way to do this. I'll try to use pure shell script, no the c code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜