From d6c4117b35536cdbbbc0106e1da187e06a298a6b Mon Sep 17 00:00:00 2001 From: "W. Eric Norum" Date: Mon, 8 Dec 2003 20:37:14 +0000 Subject: [PATCH] Add support for iocsh 'system' command. --- src/iocsh/Makefile | 1 + src/iocsh/systemCommandRegister.c | 39 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/iocsh/systemCommandRegister.c diff --git a/src/iocsh/Makefile b/src/iocsh/Makefile index cc92a2931..5a19bd388 100644 --- a/src/iocsh/Makefile +++ b/src/iocsh/Makefile @@ -49,6 +49,7 @@ LIBSRCS += asTestRegister.c LIBSRCS += envRegister.c LIBSRCS += iocUtil.c LIBSRCS += iocCoreLimitsRegister.c +LIBSRCS += systemCommandRegister.c LIBSRCS += registryRegister.c LIBRARY_IOC = iocsh diff --git a/src/iocsh/systemCommandRegister.c b/src/iocsh/systemCommandRegister.c new file mode 100644 index 000000000..222d934c2 --- /dev/null +++ b/src/iocsh/systemCommandRegister.c @@ -0,0 +1,39 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Escape to system command interpreter. To enable this command, add + * registrar(iocshSystemCommand) + * to an application dbd file. + * + * $Id$ + */ +#include +#include +#include +#include + +/* system */ +static const iocshArg systemArg0 = { "command string",iocshArgString}; +static const iocshArg * const systemArgs[1] = {&systemArg0}; +static const iocshFuncDef systemFuncDef = {"system",1,systemArgs}; +static void systemCallFunc(const iocshArgBuf *args) +{ + system(args[0].sval); +} + +static void +iocshSystemCommand(void) +{ + if (system(NULL)) + iocshRegister(&systemFuncDef,systemCallFunc); + else + errlogPrintf ("Can't register 'system' command -- no command interpreter available.\n"); +} +epicsExportRegistrar(iocshSystemCommand);