在PHP中运行着的shell脚本 [英] Cant run shell script in PHP

查看:135
本文介绍了在PHP中运行着的shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图与运行shell脚本 EXEC shell_exe 什么也没有发生!
当我和那些命令来运行 LS WHOAMI 一切工作的。

When I am trying to run shell script with exec and shell_exe nothing happens! When I run with those command ls or whoami all work's.

什么会是什么?

推荐答案

你呼应的输出?

echo exec('ls');

您已经启用safe_mode设置?

Do you have safe_mode enabled?

phpinfo();

当是:(从手动)

请注意:当启用安全模式时,你只能执行中的文件
  safe_mode_exec_dir之。出于实际的原因,它目前不允许
  有..组件中的可执行文件路径。

Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.

尝试调用exec以

exec('...pathtoyourbashscript...', $out, $return);

然后

echo $return;

如果它显示 127 可能汇入作业的路径是错误的。

If it shows 127 it´s likely that the path is wrong.

另外,还要检查权限。用户没有人可能是apache用户,需要的权限访问和执行脚本。

Also check the permissions. User 'nobody' is probably the apache user, which needs the rights to access and execute the script.

您可以通过运行更改权限

You can change the permissions by running

行chmod 755 pathtouyourscript

这意味着像'如果其他人读取或运行此文件,我不介意,但只有我应该能够修改。

This means something like 'I don't mind if other people read or run this file, but only I should be able to modify it'.

这篇关于在PHP中运行着的shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆