home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
forum16.lzh
/
SOFTWARE
/
C
/
DIV_UTILITIES
/
run.c
< prev
Wrap
C/C++ Source or Header
|
1991-03-24
|
2KB
|
73 lines
/*********************************************************************
file run.c: program description
fork a process with stdio connected to the terminal
----------------------------------------------------------------------
shorthand, name and address of authors:
MM M. Moser, Jakob-Brucker-Str. 15, 8950 Kaufbeuren
----------------------------------------------------------------------
version, author, date and report:
1.0 MM 04.02.91 initial version
----------------------------------------------------------------------
pecularities:
none
*********************************************************************/
/********** include files **********/
#include <stdio.h>
#include <strings.h>
#include "../defs/misc.h"
/********** external symbols **********/
extern char *getenv();
extern int findArg();
/********** internal definitions **********/
#define PortName "PORT"
/********** internal functions **********/
/* > help: kurze Funktionsbeschreibung und Fehlertext ausgeben */
void help()
{
/* Funktionsbeschreibung ausgeben */
printf("Syntax: run '<prgname> {<arg>}'\n");
printf("Function: execute the program <prgname> with stdio ");
printf("rebound to the terminal\n");
printf(" (be sure the argument is quoted)\n");
printf("Options:\n");
printf(" (none)\n");
}
/********** main function **********/
main(argc, argv)
int argc;
char *argv[];
{
char *p, /* name of port */
b[MaxStrLen]; /* buffer for new command line */
/* test for invalid arguments or help option */
if (argc != 2 || findArg("-?", 1, argc, argv) > 0) {
help();
exit(0);
}
/* get name of input, output and error stream */
if ((p = getenv(PortName)) == NULL)
ErrorExit("Weird - environment variable PORT not defined!\n");
/* execute the program */
sprintf(b, "%s <%s >%s >>%s", argv[1], p, p, p);
system(b);
exit(0);
}
/*************************** end of file ****************************/