0
尋找能夠自動化bash腳本獲取.PHP程序內容的能力,並在特定的目錄中以755的權限創建它。我基本上想要爲用戶提供這一個.sh腳本,該腳本將安裝相應的程序和文件以啓動並運行網站。我遇到的問題是PHP變量不會保存在輸出文件中。我正在使用以下命令:創建一個bash shell腳本,可以創建一個PHP程序
echo "<?php
header('Content-Type: text/xml');
require_once '/var/www/osbs/PHPAPI/account.php';
require_once '/var/www/osbs/zang/library/Zang.php';
$To = $_POST['subject'];
$Body = $_POST['text'];
# If you want the response decoded into an Array instead of an Object, set
response_to_array to TRUE, otherwise, leave it as-is
$response_to_array = false;
# Now what we need to do is instantiate the library and set the required
options defined above
$zang = Zang::getInstance();
# This is the best approach to setting multiple options recursively Take note that you cannot set non-existing options
$zang -> setOptions(array(
'account_sid' => $account_sid,
'auth_token' => $auth_token,
'response_to_array' => $response_to_array));
?>" | tee /var/www/output.php
output.php文件缺少所有以$開頭的變量,你們可以幫忙嗎?
當然,你不會真的想將一些PHP代碼硬編碼到你的bash腳本中嗎?它不應該只是複製文件,並可能創建一個數據庫? – ADyson
您需要在bash腳本中使用反斜槓'\ $' –
來跳過'$'或在bash腳本中使用單引號圍繞您的php代碼。 –