Создайте скрипт оболочки bash, который может создать программу PHP

Ищете возможность автоматизировать возможность bash-скрипта брать содержимое программы .PHP и создавать его в определенном каталоге с разрешениями 755. Я в основном хочу предоставить пользователю один .sh-скрипт, который установит соответствующий программы и файлы для запуска сайта. Проблема, с которой я сталкиваюсь, заключается в том, что переменные 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 отсутствуют все переменные, начинающиеся с $.

0

Решение

Самый простой способ справиться с проблемами цитирования здесь — это использовать «Здесь-док»:

cat >/var/www/output.php <<"EOF"<?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 ));
?>
EOF

Там нет необходимости tee (если вы действительно не хотите выгружать все эти вещи в консоль, что кажется ненужным). Цитирование строки-разделителя (<<"EOF") эффективно цитирует весь Here-doc, предотвращая расширение переменных.

1

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]