如何从 php 传递参数调用 bash 脚本
我有一个执行 bash 脚本的 php 脚本。我尝试像这样传递参数:
$script="/opt/lampp/htdocs/adapt.sh"
$file="/opt/lampp/htdocs/videos/video1.mp4"
$prefix="Test"
exec ('.$script.' '.$file.' '.$prefix.');
出了什么问题?我该如何传递参数?
I have a php script that execute a bash script. I try to pass parameters like this:
$script="/opt/lampp/htdocs/adapt.sh"
$file="/opt/lampp/htdocs/videos/video1.mp4"
$prefix="Test"
exec ('.$script.' '.$file.' '.$prefix.');
What's wrong? How can I pass the parameters?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的点在错误的地方,应该阅读:
或更具可读性
You have your dots in the wrong place, should read:
or more readable
这是错误的:
小心引号:-)
this is wrong:
be carefull with quotes :-)
我不太明白你的问题是什么,但你的 exec() 调用应该如下所示:
如果你接受来自外部的参数(例如来自 GET 或 POST 参数),请务必使用
escapeshellarg()
出于安全原因在参数上。I dont really understand what your question is, but your exec() call should look like this:
If you accept parameters from outside (e.g. from a GET or POST parameter), be sure to use
escapeshellarg()
on the arguments for security reasons.