我遇到了此execve
命令的問題。我可以用它在我的程序中運行大多數其他命令,但是如果我嘗試像man ls
或其他東西那樣得到此錯誤。execve error當調用execve(man,args,env)
man: can't execute pager: No such file or directory
man: command exited with status 255: LESS=-ix8RmPm Manual page ls(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page ls(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$ MAN_PN=ls(1) pager -s
這裏是我怎樣,我稱之爲:
execve(cmdPath, args, env);
其中cmdPath
是路徑(在這種情況下/usr/bin/man
) args
是char*
其中args[0] = man
,args[1] = ls
env
是我env*[]
從傳遞主要。
任何幫助將不勝感激。我在這裏死去。
可以運行'男人ls'正確地從您用來啓動程序相同的殼呢? – us2012 2013-02-10 05:23:52
耶只好。 – 2013-02-10 05:24:53
你可以用'args [0] = ls' – Ganesh 2013-02-10 05:46:18