LinuxSir.cn,穿越时空的Linuxsir!

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

PHP求助

[复制链接]
发表于 2005-2-23 10:16:21 | 显示全部楼层 |阅读模式
gcc.php的内容如下:
<?php
$cmd="gcc -o /tmp/out /tmp/out.c";
system($cmd);
system("/tmp/out");
?>

/tmp下out.c内容如下:
#include <stdio.h>
main()
{
   printf("you are successful\n")
}

如果在终端用 gcc -o /tmp/out /tmp/out.c
会有输出如下
out.c: In function `main':
out.c:5: error: syntax error before '}' token

但在浏览器下调用gcc.php时却得不到如上的输出,我想在浏览器下调用gcc.php时得到编译输出,请问该怎么做?

QQ:158496001
 楼主| 发表于 2005-2-23 10:23:22 | 显示全部楼层

PHP求助

gcc.php的内容如下:
<?php
$cmd="gcc -o /tmp/out /tmp/out.c";
system($cmd);
system("/tmp/out");
?>

/tmp下out.c内容如下:
#include <stdio.h>
main()
{
printf("you are successful\n")
}

如果在终端用 gcc -o /tmp/out /tmp/out.c
会有输出如下
out.c: In function `main':
out.c:5: error: syntax error before '}' token

但在浏览器下调用gcc.php时却得不到如上的输出,我想在浏览器下调用gcc.php时得到编译输出,请问该怎么做?

QQ:158496001
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-2-23 10:24:07 | 显示全部楼层

PHP求助

gcc.php的内容如下:
<?php
$cmd="gcc -o /tmp/out /tmp/out.c";
system($cmd);
system("/tmp/out");
?>

/tmp下out.c内容如下:
#include <stdio.h>
main()
{
printf("you are successful\n")
}

如果在终端用 gcc -o /tmp/out /tmp/out.c
会有输出如下
out.c: In function `main':
out.c:5: error: syntax error before '}' token

但在浏览器下调用gcc.php时却得不到如上的输出,我想在浏览器下调用gcc.php时得到编译输出,请问该怎么做?

QQ:158496001
回复 支持 反对

使用道具 举报

发表于 2005-2-23 10:35:50 | 显示全部楼层
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-2-24 14:50:34 | 显示全部楼层
Post by harrypotter
reference to:
http://cn.php.net/manual/en/function.system.php


谢谢版主,在这个上面我查到了一个能实现我想要功能的函数proc_open!!!!
谢谢!! :thank
回复 支持 反对

使用道具 举报

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

本版积分规则

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