2014-02-05 189 views
0

我有一個關於交互PHP和Linux系統的問題。從PHP運行腳本

我想從網頁推出蒸汽,而這個頁面的地址是

http://site.eu/cp/user/services/21/steaminstall 

並從那裏IM運行命令

/var/www/wwwuser/data/www/site.eu/panel.php?(here goes $_POST[''] data) 

和Steam客戶端是

內部路徑與網頁
/var/www/wwwuser/data/Steam/SteamInstall 

事情是,我知道如何訪問這個腳本,我也可以執行簡單的

echo "Script is Runing" 

但是,當我的行動來驗證碼

#!/bin/bash 
wget -P /var/www/aftersoft/data/Servers/Steam/ http://media.steampowered.com/client/steamcmd_linux.tar.gz && 
tar xvfz /var/www/aftersoft/data/Servers/Steam/steamcmd_linux.tar.gz -C /var/www/aftersoft/data/Servers/Steam/ && 
sh /var/www/aftersoft/data/Servers/Steam/steamcmd.sh +login anonymous +quit && 
rm /var/www/aftersoft/data/Servers/Steam/steamcmd_linux.tar.gz && 
echo "Steam Installation and Update Completed" 

如果IM從網頁上運行它,它沒有做任何事情,但它工作時我嘗試SSH用戶下運行(與阿帕奇用戶有權寫入這個文件夾)

所以我的問題,我做錯了什麼?

UPDATE: 我的PHP代碼運行腳本

if($path[2] === 'steaminstall') 
{ 
    $InstallSteam = exec('/var/www/aftersoft/data/Servers/Steam/SteamInstall', $Output, $Error); 
    if($Error === 0) 
    { 
     $Status = $DB->SteamStatus($_SESSION['username']); 
     if($Status) 
     { 
     header('Location: /cp/'.$_SESSION['username'].'/services/'); 
     } 
     else 
     { 
     $Smarty->assign('InstallStatus', 'Database Error Occured'); 
     $Smarty->display('steaminstall.tpl'); 
     } 
    } 
    if($Error === 2) 
    { 
     $Smarty->assign('InstallStatus', $Output); 
     $Smarty->display('steaminstall.tpl'); 
    } 
} 

這是我的數據庫查詢功能

public function SteamStatus($Username) 
{ 
    $Status = '1'; 
    $Statement = $this->DBConnection->prepare("UPDATE account set steaminstalled = ? where username = ?"); 
    $Statement->bindParam(1, $Status); 
    $Statement->bindParam(2, $Username); 
    $IStatus = $Statement->execute(); 
    if($IStatus) 
    { 
     return true; 
    } 
    else 
    { 
     return false; 
    } 
} 
+0

你能提供關於你的php代碼的更多細節嗎? –

+0

編輯拳頭帖子 –

回答

0

問題解決了,你只需要指定腳本直接路徑(如果你不知道,腳本本身不知道在哪裏下載和從哪裏提取)

所以f inal bash腳本(PHP部分非常好):

#!/bin/bash 
wget -P /var/www/aftersoft/data/Servers/Steam/ http://media.steampowered.com/client/steamcmd_linux.tar.gz && 
tar xvfz /var/www/aftersoft/data/Servers/Steam/steamcmd_linux.tar.gz -C /var/www/aftersoft/data/Servers/Steam/ && 
sh /var/www/aftersoft/data/Servers/Steam/steamcmd.sh +login anonymous +quit && 
rm /var/www/aftersoft/data/Servers/Steam/steamcmd_linux.tar.gz && 
echo "Steam Installation and Update Completed"