簡體   English   中英

在服務器上運行bash腳本

[英]Running bash script on server

我想為我的遠程服務器創建一個網頁控制頁面。

我希望能夠通過按網頁上的按鈕來運行自己的本地腳本。

我遵循了(stackoverflow)的一些建議,並創建了以下代碼:

<?php if (isset($_POST['button'])) { exec('//xxx.yy.zz.v/Users/me/webtest.sh'); } ?>
<form action="" method="post">
    <button type="submit" name="button">MY TEXT</button>
</form>

webtest.sh:

#!/bin/sh
set -x

echo "WOW ME" > /cygdrive/d/jobs/web.test

當我按下按鈕時,似乎不會運行webtest.sh。

首先檢查這一行exec('//xxx.yy.zz.v/Users/me/webtest.sh'); 要從php執行sh文件,您需要使用./path/file.sh或sh path / file.sh

可以是exec('./path/file.sh') ,然后為webtest.sh和web.test設置適當的文件許可權,以便Web服務器可以訪問這些文件。 您可以檢查錯誤日志

tail -f /var/log/apache or http/errorlogs

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM