返回信息流☆─────────────────────────────────────☆
seraphy (Seraph with no wings) 于 (Wed Aug 29 15:53:13 2007) 提到:
linux环境下,
exec($cmd,$ar,$status),一个外部程序老没有结果,$status老为1
$cmd="ls -la ../../"没有问题
但是$cmd="ls -la ../../dir"就有问题了
还有比如运行snmp -v 2c -c public ip都有问题,命令行里直接运行都没有问题,这到底是什么问题啊??
☆─────────────────────────────────────☆
chit (chit) 于 (Wed Aug 29 15:56:14 2007) 提到:
shell_exec()
换这个看看
另外如果是外部命令最好写全路径
和运行PHP的用户是否有权限的问题
【 在 seraphy (Seraph with no wings) 的大作中提到: 】
: linux环境下,
: exec($cmd,$ar,$status),一个外部程序老没有结果,$status老为1
: $cmd="ls -la ../../"没有问题
: ...................
☆─────────────────────────────────────☆
seraphy (Seraph with no wings) 于 (Wed Aug 29 15:59:20 2007) 提到:
试过了
不行
用户??我都是用的root
☆─────────────────────────────────────☆
seraphy (Seraph with no wings) 于 (Wed Aug 29 16:06:34 2007) 提到:
对了,帅哥,怎么才能以root去运行外部程序呢??
☆─────────────────────────────────────☆
chit (chit) 于 (Wed Aug 29 16:48:25 2007) 提到:
帅哥
你不是说你已经用root了么?
在shell环境下 直接用 php XXX.php 就可以了阿
【 在 seraphy (Seraph with no wings) 的大作中提到: 】
: 对了,帅哥,怎么才能以root去运行外部程序呢??
☆─────────────────────────────────────☆
seraphy (Seraph with no wings) 于 (Wed Aug 29 17:35:06 2007) 提到:
不行啊,是在网页里运行的
我用exec了whoami发现是nobody啊
我怎么才能变成root呢??
☆─────────────────────────────────────☆
fbsd (烈火) 于 (Wed Aug 29 17:47:55 2007) 提到:
apache运行帐户和组改成root,具体看httpd.conf..
【 在 seraphy (Seraph with no wings) 的大作中提到: 】
: 不行啊,是在网页里运行的
: 我用exec了whoami发现是nobody啊
: 我怎么才能变成root呢??
: ...................
☆─────────────────────────────────────☆
seraphy (Seraph with no wings) 于 (Wed Aug 29 17:49:09 2007) 提到:
呵呵,这个听起来很可行~~~
☆─────────────────────────────────────☆
chit (chit) 于 (Wed Aug 29 18:15:12 2007) 提到:
哈哈
应该不行
httpd一般情况下是不允许以root组运行了
【 在 seraphy (Seraph with no wings) 的大作中提到: 】
: 呵呵,这个听起来很可行~~~
☆─────────────────────────────────────☆
seraphy (Seraph with no wings) 于 (Wed Aug 29 21:42:58 2007) 提到:
恩,对,不行
那应该怎么办呢???
再创建一个用户,然后把snmp授权给这个用户??
【 在 chit 的大作中提到: 】
: 哈哈
: 应该不行
: httpd一般情况下是不允许以root组运行了
☆─────────────────────────────────────☆
chit (chit) 于 (Wed Aug 29 21:46:03 2007) 提到:
这样应该是可以的你建一个用户
然后再配置文件里面把运行httpd的用户和组都设置为这个用户
这样的话只要你su - 这个用户能执行的命令通过httpd就应该可以运行
所以归根到底还是我最开始说的,权限的问题
呵呵
【 在 seraphy (Seraph with no wings) 的大作中提到: 】
: 恩,对,不行
: 那应该怎么办呢???
: 再创建一个用户,然后把snmp授权给这个用户??
: ...................
☆─────────────────────────────────────☆
seraphy (Seraph with no wings) 于 (Thu Aug 30 09:59:15 2007) 提到:
哎,郁闷啊,不知道cacti是怎么做的
我看他也是直接调用的exec,没有仔细看实现
☆─────────────────────────────────────☆
chit (chit) 于 (Thu Aug 30 10:13:09 2007) 提到:
cacti应该是通过snmp读取的数据
其实php可以自己带snmp模块
编译的时候加进去就好了
没有必要调用外部命令
【 在 seraphy (Seraph with no wings) 的大作中提到: 】
: 哎,郁闷啊,不知道cacti是怎么做的
: 我看他也是直接调用的exec,没有仔细看实现
☆─────────────────────────────────────☆
seraphy (Seraph with no wings) 于 (Thu Aug 30 12:51:23 2007) 提到:
是通过snmp读取,但是snmp是属于root用户的阿~
php自带的模块功能太弱
只能得到一些值,walk的时候得不到下级的oid
【 在 chit 的大作中提到: 】
: cacti应该是通过snmp读取的数据
: 其实php可以自己带snmp模块
: 编译的时候加进去就好了
: ...................
☆─────────────────────────────────────☆
chit (chit) 于 (Thu Aug 30 13:17:24 2007) 提到:
属于root用户不等于其他用户不能用
我前面的文章已经告诉你怎么做了
【 在 seraphy (Seraph with no wings) 的大作中提到: 】
: 是通过snmp读取,但是snmp是属于root用户的阿~
: php自带的模块功能太弱
: 只能得到一些值,walk的时候得不到下级的oid
: ...................
这是一条镜像帖。来源:北邮人论坛 / www-technology / #3276同步于 2008/5/27
该镜像源已超过 30 天没有更新,可能在源站已被删除。
WWWTechnology机器人发帖
[合集] [求助]有关php的exec函数问题
tntzwz
2008/5/27镜像同步0 回复
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。