bashスクリプトが.PHPプログラムの内容を取得し、権限が755の特定のディレクトリに作成する機能を自動化する機能を探しています。ユーザーにこの1つの.shスクリプトを与え、適切なプログラムとファイルをインストールしてWebサイトを起動して実行させます。私が実行している問題は、PHP変数が出力ファイルに保存されないことです。PHPプログラムを作成できるbashシェルスクリプトを作成する
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ファイルは君たちを助けることができる$で始まるすべての変数が欠落しています。私は、次のコマンドを使用していますか?
あなたは、文字通り、あなたのbashスクリプトにいくつかのPHPコードをハードコードしたくないのですか?単にファイルをコピーしたり、データベースを作成したりするべきではありませんか? – ADyson
バックスラッシュ '\ $' –
でbashスクリプトの '$'をエスケープするか、bashスクリプトのPHPコードの前後に一重引用符を使用する必要があります。 –