Python中文
首页
教程
问答
标签
搜索
登录
注册
如何使用php执行shell cmd(python)并打印所有constantupdated输出?
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>实际上,我对php还很陌生。所以事情是这样的: 我想为著名的youtube dl制作一个简单的web shell,所以我制作了一个简单的网页和一个简单的php页面,尝试使用php来执行youtube dl并将所有输出显示到浏览器。在</p> <p>我尝试过<code>command</code>和escapeshellcmd(),它们都可以从youtube dl中输出最初几行不断更新的输出(它们可以很好地与其他命令如“ls”配合使用),但似乎当它得到第一行时,python脚本就会停止,不再更新,我的服务器上也没有下载的视频文件。在</p> <p>顺便说一句,都是在Ubuntu 14 LTS上。在</p> <p>到目前为止,我已经试过了:</p> <pre><code> <?php $command = shell_exec('youtube-dl https://www.youtube.com/watch?v=z456k6yBeo0'); echo "<pre>$command</pre>"; ?> </code></pre> <p>以及</p> ^{pr2}$ <p>以及</p> <pre><code> <?php $command = escapeshellcmd('youtube-dl https://www.youtube.co/watch?v=z456k6yBeo0'); $output = shell_exec($command); echo $output; ?> </code></pre> <p>它们都能很好地与“ls”配合使用,但与youtube dl的配合却不太好</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>所以我设法解决了这个问题。@zahyur是对的,这是关于许可的问题。由于我习惯使用root来管理我的服务器,所以当我从shell执行命令时不会有任何问题。但是服务器需要额外的权限才能执行命令,以便在目录中写入内容。在</p> <p>解决方案是建立一个新目录并赋予它写访问权限,在该目录中执行命令,就不会出现问题。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何添加虚拟方法
4 回答
如何添加表示整数的擦边字符串?
5 回答
如何添加要在Bokeh中使用的新font.ttf文件?
7 回答
如何添加要显示的矩阵XY轴编号和XY轴
3 回答
如何添加计数?
7 回答
如何添加计数器函数?
8 回答
如何添加计数器列来计算数据帧中另一列中的特定值?
8 回答
如何添加计数器来跟踪while循环中的月份和年份?
6 回答
如何添加计数并删除countplot的顶部和右侧脊椎?
3 回答
如何添加计时器wx.应用程序更新窗口对象的主循环?
8 回答
如何添加评论到帖子?PostDetailVew,Django 2.1.5
10 回答
如何添加评论拉梅尔亚姆
3 回答
如何添加诸如矩阵Python/Pandas之类的数据帧?
2 回答
如何添加谷歌地点自动完成到Flask?
4 回答
如何添加超时、python discord bot
4 回答
如何添加超过1dp的检查
3 回答
如何添加距离方法
7 回答
如何添加跟随游戏的敌人精灵
3 回答
如何添加路径以便python可以找到程序?
6 回答
如何添加身份验证/安全性以使用happybase访问HBase?
1 回答