Chinaunix首页 | 论坛 | 博客
  • 博客访问: 571318
  • 博文数量: 141
  • 博客积分: 3425
  • 博客等级: 中校
  • 技术积分: 1609
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-23 15:55
文章分类

全部博文(141)

文章存档

2019年(5)

2011年(19)

2010年(36)

2009年(13)

2008年(50)

2007年(18)

分类: C/C++

2007-10-28 22:32:08

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



阅读(1554) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~