system
--------------------------------------------------------------------------------
Executes a shell command
#include
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
阅读(1585) | 评论(0) | 转发(0) |