从网页运行bash的文件 [英] Run bash file from web page

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

问题描述

好了,所以我有一个bash文件,做一个Linux服务器上的各种操作。

Ok so I have a bash file that does various operations on a linux server.

我需要通过7-8变量bash的文件,而这些变量将通过用户在一个简单的网页来设定。

I need to pass 7-8 variables to the bash file, and these variables will be set by a user on a simple webpage.

只是想知道,如果这是可能的,或者我需要编写脚本通过一些其他语言的bash文件的电话吗?

Just wondering if this is possible or do I need to script the bash file call through some other language?

展望从 HTTP调用一个bash文件功能://www.tldp .ORG / LDP / ABS / HTML / functions.html 这是正确的方向?

Looking into calling functions on a bash file from http://www.tldp.org/LDP/abs/html/functions.html is this the right lines?

似乎无法找到一个很好的资源来指导我在这所以任何链接或例子AP preciated

can't seem to find a good resource to guide me on this so any links or examples appreciated

推荐答案

如果您在Web服务器上运行PHP,那么你可以发表你的Web表单PHP脚本,然后使用PHP的了shell_exec ()函数来调用你的bash脚本,并通过输入。正如上面paulsm4提到,任何时候你调用一个shell脚本,并从网上通过输入一个shell脚本,你必须非常小心地消毒输入prevent注入式攻击。这样做的一个办法是做所有的验证和消毒的PHP脚本,通过了shell_exec()方式调用shell脚本,以确保您只通过清洁输入shell脚本之前。

If you're running PHP on the web server, then you can post your web form to a PHP script, then use PHP's shell_exec() function to call your bash script and pass the inputs. As paulsm4 mentions above, any time you call a shell script and pass inputs to a shell script from the web, you need to be very careful to sanitize the inputs to prevent injection type of attacks. One way to do this is to do all the validation and sanitization in the PHP script, before calling the shell script by way of shell_exec() to ensure that you are passing only clean input to the shell script.

请参阅http://php.net/manual/en/function.shell-exec.php

这篇关于从网页运行bash的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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