Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
创建一个bashshell脚本,该脚本可以创建一个PHP程序_Php_Bash_Sh_Tee - Fatal编程技术网

创建一个bashshell脚本,该脚本可以创建一个PHP程序

创建一个bashshell脚本,该脚本可以创建一个PHP程序,php,bash,sh,tee,Php,Bash,Sh,Tee,正在寻找自动化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/li

正在寻找自动化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
echo”“| tee/var/www/output.php

output.php文件缺少所有以$开头的变量。你们能帮忙吗

处理此处报价问题的最简单方法是使用:

cat>/var/www/output.php
EOF

没有必要使用
tee
(除非您真的想将所有这些内容转储到控制台,这似乎是不必要的)。引用分隔符字符串(
你肯定不想硬编码一些PHP代码到你的bash脚本中吗?难道不应该只是复制文件,或者创建一个数据库吗?你需要用反斜杠
\$
来转义bash脚本中的
$
,或者在bash脚本中的PHP代码周围使用单引号。
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