Outils pour utilisateurs

Outils du site


francois:launching_a_shell_script_programmatically

Launching a Shell Script Programmatically

The following code illustrates how to launch a script programmatically (using the command interpreter):

VxRun.c
#include <vxWorks.h>
#include <stdio.h>
#include <ioLib.h>
#include <string.h>
#include <errnoLib.h>
#include <sysLib.h>
#include <shellLib.h>
#include <taskLib.h>
 
STATUS runScript
(
char * scriptPath /* full path to script to execute */
)
{
char * shellTaskName;
int fdScript;
STATUS retVal = ERROR;
 
if ((fdScript = open (scriptPath, O_RDONLY, 0)) == ERROR)
{
printErr ("Error opening script at '%s' [%s]!\n", scriptPath,
strerror (errnoGet ()));
return retVal;
}
 
/* Launch a new session to execute the script */
 
retVal = shellGenericInit ("INTERPRETER=Cmd", 
                           0, 
                           NULL, 
                           &shellTaskName, 
                           FALSE, 
                           FALSE, 
                           fdScript, 
                           STD_OUT, 
                           STD_ERR);
 
/* Wait for the script execution to end by monitoring the shell task life */
 
do
taskDelay (sysClkRateGet ());
while (taskNameToId (shellTaskName) != TASK_ID_ERROR);
 
close (fdScript);
return retVal;
}
francois/launching_a_shell_script_programmatically.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki