StreamDevice can do that.
You will have to write iocsh function, which you can call from StreamDevice.
That iocsh function (programmed in C/C++) will call the system C-function with your script as an argument.
Note that to use StreamDevice, you don't need a physical device (i.e. your protocol can just call your function)
int dmc2183_escapeToShell(const char *p_command) {
int status;
status=system(p_command);
switch(status) {
case ERROR:
printf("[ERROR] %s\n", p_command);
break;
case SUCCESS:
funcLog(7, __FILE__ "[%d] SUCCESS\n", __LINE__);
break;
default:
printf("[ERROR] status=%d\n", status);
break;
}
return(SUCCESS);
}
static const iocshArg dmc2183_escapeToShellArg0 = {"Command", iocshArgString};
static const iocshArg* const dmc2183_escapeToShellArgs[1] = {
&dmc2183_escapeToShellArg0};
static const iocshFuncDef dmc2183_escapeToShellFuncDef = { "dmc2183_escapeToShell",1,dmc2183_escapeToShellArgs};
static void dmc2183_escapeToShellCallFunc(const iocshArgBuf* args) { dmc2183_escapeToShell(args[0].sval);
}
static void DMC2183_iocshFuncRegistrar (void) {
iocshRegister( &dmc2183_escapeToShellFuncDef, dmc2183_escapeToShellCallFunc);
}
epicsExportRegistrar(DMC2183_iocshFuncRegistrar);
Enjoy,
--
Emmanuel
> Date: Tue, 1 Oct 2013 18:44:19 +0200
> From:
[email protected]> To:
[email protected]> Subject: how to issue a shell command from EPICS record ?
>
> Hi
> Hope someone has a good advice for me:
>
> I implemented an XY-scanning table control using EPICS to handle an XY
> step-motor table.
> I use sscan records to implement automatic scans in x and xy-direction.
> So far this works fine.
>
> Now i want to add one more thing: Before the scan starts, i have to
> start the DAQ system with a certain BASH shell-script, after the scan i
> have to stop the DAQ with another shell script.
>
> Can i somehow issue these shell-commands automatically before and after
> the scan ?
> Is there some record type available which can do this ???
>
> I have been quite some time now, but could not find anything.
>
> Any advice ?
>
> best regards,
> Christian