我需要在vxWorks 6.7中执行一个脚本。这可以用vxworks 5.5中的execute()函数来完成。我正在应用的解决方案是使用stdin重定向,如下代码所示:
newStdIn = open("myScript.txt",O_RDONLY,0644);
oldStdIn=ioGlobalStdGet(STD_IN);
ioGlobalStdSet(STD_IN, newStdIn);
/*Read file here and execute*/
ioGlobalStdSet(STD_IN,oldStdIn); /*Restore old stdIn*/
close(newStdIn);
我遗漏了读和执行部分(注释在其中)。
编辑:根据vxworks内核程序员指南,执行脚本的方法如下:
fdScript = open ("myScript", O_RDONLY);
shellGenericInit ("INTERPRETER=Cmd", 0, NULL, &shellTaskName, FALSE, FALSE, fdScript, STD_OUT, STD_ERR);
do
taskDelay (sysClkRateGet ());
while (taskNameToId (shellTaskName) != ERROR);
close (fdScript);
但是它将在不处理脚本的情况下打开一个新的shell。问题是,在调用shellGenericInit之后,我的应用程序不会做任何事情。
发布于 2014-11-19 14:54:26
看起来您正在启动一个Cmd shell,而不是一个C解释器shell。由于您在5.5中提到使用了execute()函数,我假设您的脚本是为C解释器编写的。
尝试将"INTERPRETER=Cmd“改为"INTERPRETER=C”。
https://stackoverflow.com/questions/25529269
复制相似问题