LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1097|回复: 4

system的执行问题

[复制链接]
发表于 2007-10-10 18:19:33 | 显示全部楼层 |阅读模式
php程序:
<?php
system("/root/phptest");
?>
phptest.c:
#include <stdio.h>
void main()
{
      char str[]="success!";
      printf("%s\n",str);
}

直接运行phptest是没问题的,成功输出.
我把这个php程序写在/var/www/html下,访问运行的结果是页面空白,什么没显示.
请问高手,system函数怎样才能使用啊?php的安全模式我已经设置为off了(safe_mode=off),是权限问题吗?还是其他??
求教!!
 楼主| 发表于 2007-10-11 09:23:09 | 显示全部楼层
请高手不要吝啬啊,回复一下
回复 支持 反对

使用道具 举报

发表于 2007-10-11 09:33:52 | 显示全部楼层
用  passthru 函数
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-10-11 09:48:20 | 显示全部楼层
Post by AMD-K6
用  passthru 函数


同样没结果,exec也一样,为什么啊???
回复 支持 反对

使用道具 举报

发表于 2007-10-12 16:52:07 | 显示全部楼层



  1. system
  2. (PHP 3, PHP 4, PHP 5)

  3. system -- Execute an external program and display the output
  4. 说明
  5. string system ( string command [, int &return_var] )


  6. system() is just like the C version of the function in that it executes the given command and outputs the result.

  7. The system() call also tries to automatically flush the web server's output buffer after each line of output if PHP is running as a server module.

  8. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function.

  9. 参数


  10. command
  11. The command that will be executed.

  12. return_var
  13. If the return_var argument is present, then the return status of the executed command will be written to this variable.


  14. 返回值
  15. Returns the last line of the command output on success, and FALSE on failure.
复制代码


system 返回的是 stdout 的字符,所以:

[PHP]
echo system("ls");
[/PHP]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表