开发者

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

开发者 https://www.devze.com 2023-02-22 20:58 出处:网络
In my c progr开发者_StackOverflow社区am, I want to launch a script by popen(). like this: char mimetype[256];

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

精彩评论

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

关注公众号