PHP 中 Wget 的问题
如果我在 shell 中运行命令,它会下载它,shell 没有错误
,但 PHP 页面总是会转到 if 语句,
我尝试了 shell_exec ,结果是相同的,
我真的想这样做Wget
但是,如果这是不可能的,并且您的解决方案是 cURL
,请告诉它更多详细信息,然后我可以找到如何编码
$flag=system('wget -P /srv/www/htdocs/didebansnort/Downloads http://www.snort.org/reg-rules/snortrules-snapshot-2900.tar.gz/myoinkcodethatmustbesecret
');
if(!$flag)
{
echo '<script>alert("please try again!")</script>';
}
如果问题与权限有关,我该如何修复它?
建议已开放 但我必须从命令行下载 如果你觉得可以的话!
这是网站
https://www.snort.org/snort-rules/#rules
例如,右键单击 snortrules-snapshot-2904.tar.gz 我可以拥有它 现在我认为通过 fopen 是不可能的,我怎样才能访问它? 我认为解决方案“只是”通过 PHP 命令行下载 我不知道!
谢谢
if I run the command in shell it will download it,No error by shell
but by PHP page always it goes to if statement
I tried shell_exec
and the result is the same
I really want to do it just by Wget
But if this is impossible and your solution is cURL
please tell it in more details then I can find out how to code it
$flag=system('wget -P /srv/www/htdocs/didebansnort/Downloads http://www.snort.org/reg-rules/snortrules-snapshot-2900.tar.gz/myoinkcodethatmustbesecret
');
if(!$flag)
{
echo '<script>alert("please try again!")</script>';
}
If the problem is about permissions How can I fix it?
suggestion was fopen
but I have to download from command line
If you think it is possible!
here is the site
https://www.snort.org/snort-rules/#rules
well for example by rightclick on snortrules-snapshot-2904.tar.gz
I can have it
now I think it is impossible by fopen how can I make access to it?
I think solution is "just" download via command line in PHP
I don't know!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确定您的 PHP 配置允许您执行 system() 并且允许您以 root 身份运行它吗?
Are you sure your PHP config allows you to execute system() and that it allows you to run it as root?
sudo 以哪个用户身份运行?该用户是否可以无密码访问 root(如果是,为什么!)您确实需要避免 sudo 位,它很可能会失败。只需确保用户 PHP 运行时可以写入 /srv/www/htdocs/didebansnort/Downloads(了解其中的风险)并在不使用 sudo 的情况下运行 wget 即可。
更好的是,为什么不使用 PHP 的内置方法之一来获取远程文件呢? (
fopen
?)Which user is the sudo running as? Does that user have passwordless access to root (if so, why!) You really need to avoid the
sudo
bit, it's very probably failing. Just make sure the user PHP runs as can write to /srv/www/htdocs/didebansnort/Downloads (understanding the risks there-of) and run the wget without thesudo
.Even better, why not use one of the built in methods of PHP to get a remote file? (
fopen
?)