终端命令“转换”在C程序中找不到

时间:2013-10-16 16:36:04

标签: c terminal command system

我正在尝试使用系统函数在C程序中使用convert terminal命令,这是代码片

\#include <stdlib.h>
...
system("cd /Users/myUser/Desktop/photos/pgm;for i in *.jpg; do convert $i 
-compress none  -scale     32x24! $i.pgm; done;")   

但是我无法运行convert命令,这是程序输出:

sh: convert: command not found 

我可以在终端中运行相同的命令而没有问题

1 个答案:

答案 0 :(得分:3)

使用convert检查which convert的完整路径。 然后在C程序中交换完整路径。