shellscript als C-Programm ?

Post Reply
Message
Author
shell

shellscript als C-Programm ?

#1 Post by shell »

hi

wie kann ich einen vorhandenes Shellscript in einen C-Source einfügen ?
hab mal gehört, daß man sowas mit system (<command>); ausführen kann. Da ich mit C unter linux keinerlei Erfahrung habe, bitte ich um Hilfe. Das einzigste, was ich weiß ist, daß GNU installiert ist ;)

DANKE

Sulu

Re: shellscript als C-Programm ?

#2 Post by Sulu »

Es geht genauso wie Du sagst.
Im C-Pogramm
system("name-des-auszuführenden-scripts");
einbauen.
Die notwendigen Include-Dateien sind in der man-page beschrieben, also man system.
Beispiel:
/*SYSTEM CALLS
Calls may be made to the Operating System to execute standard OPsys calls, eg, */

#include <process.h>
main() /* SYS.C */
{
char *command = "dir";

system( "cls" );
system( command );
}

/*Do not use this method to invoke other programs. Functions like exec() and spawn() are used for this. */

--------------------------

Gruss
Sulu

shell

Danke

#3 Post by shell »

wenn ich das hab, wie linke ich es bzw. wie ruf ich den kompiler auf ?

danke

Post Reply