Redirecting to stdin in order to execute script in vxworks 6.7

Deadly 提交于 2019-12-08 01:08:33

问题


I need to execute a script in vxWorks 6.7. It can be done with the execute() function in vxworks 5.5. The solution that I am applying is to use stdin redirection as in the following code:

    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);

I am missing the read and execute part (where the comment is).

EDIT: According to the vxworks kernel programmers guide, the way to execute a script is as follows:

    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);

But it will open a new shell without processing the script. The problem with this is that my application won't do anything after calling shellGenericInit.


回答1:


It looks like you are starting a Cmd shell, rather than a C Interpreter shell. Since you mention that you used the execute() function in 5.5, I assume that your script is for the C Interpreter.

Try changing "INTERPRETER=Cmd" to "INTERPRETER=C".



来源:https://stackoverflow.com/questions/25529269/redirecting-to-stdin-in-order-to-execute-script-in-vxworks-6-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!