1 #include <stdio.h> /* standard io library */
2 #include <stdlib.h> /* standard library */
3 #include <unistd.h> /* sleep , fork & exec */
4 #include <string.h> /* standard string library */
7 int main ( int argc, char *argv[] )
9 /*char cmd [32000] = "lyx " ; */ /* user command */
10 char cmd [32000] = "lyx " ;
11 char *nargs [4 ] = { "/bin/bash", "-c" , cmd , NULL } ; /* execute with login /bin/bash */
14 putenv ( "BASH_ENV=/etc/lyxprofile" ) ; /* ensure bash reads my global env changes */
16 while ( i < argc ) /* do for all "real" args */
18 strcat ( cmd , "\"" ) ; /* add quote before */
19 strcat ( cmd , argv [ i ] ) ; /* add the argument */
20 strcat ( cmd , "\" " ) ; /* add closing quote */
24 strcat ( cmd, "</dev/null 2>/dev/null");
26 fprintf ( stderr , "Command is: |%s|\n" , cmd );
27 execv ( "/bin/bash" , nargs ) ; /* exec sub command */
29 /* we should never reach here */
30 fprintf ( stderr , "Execute failed, error = %d\n" , errno ) ;
31 return ( 0 ) ; /* exit with no error */