shell,如果我想跑與交流計劃的Linux shell命令,我會用我爲什麼能寫入VxWorks的命令與交流計劃
system("ls");
有沒有一種方法可以讓我在風河做到這一點VxWorks的?
我發現了下面的例子,但我想知道是否需要包含vxworks頭文件才能工作?我假設我這樣做,但我怎麼弄清楚哪一個?
例子:
// This function runs a shell command and captures the output to the
// specified file
//
extern int consoleFd;
typedef unsigned int (*UINTFUNCPTR)();
extern "C" int shellToFile(char * shellCmd, char * outputFile)
{
int rtn;
int STDFd;
int outFileFd;
outFileFd = creat(outputFile, O_RDWR);
printf("creat returned %x as a file desc\n",outFileFd);
if (outFileFd != -1)
{
STDFd=ioGlobalStdGet(STD_OUT);
ioGlobalStdSet(STD_OUT,outFileFd);
rtn=execute(shellCmd);
if (rtn !=0)
printf("execute returned %d \n",outFileFd);
ioGlobalStdSet(STD_OUT,STDFd);
}
close(outFileFd);
return (rtn);
}
哪個版本的vxWorks? – indiv 2010-10-14 19:36:45