system


system

Executes a shell command

 #include <stdlib.h> int system ( const char *s  ); 

The system( ) function passes a command line addressed by the pointer argument s to an operating system shell. If s is a null pointer, the function returns true (a nonzero value) if a command processor is available to handle shell commands, and 0 or false if not.

How the system executes a command, and what value the system( ) function returns, are left up to the given implementation. The command may terminate the program that calls system( ), or have unspecified effects on its further behavior.

Example

 if ( system( NULL ))   system( "echo \"Shell: $SHELL; process ID: $$\""); else   printf( "No command processor available.\n" ); 

This example is not portable, but on certain systems it can produce output like this:

 Shell: /usr/local/bin/bash; process ID: 21349 

See Also

getenv( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net