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代码。 –