我得跑了
eval "php /srv/www/script/mage/install-invoke-app.php“
它找到了该文件,但最终却以

在<?php上搞砸了。为什么?怎么解决的?谷歌到目前为止还没有给出正确的答案。
update这里是一个脚本,它是一个函数,然后我传递一个回调..有好几吨被剥掉了,所以只限于这个地区。
在包含base.sh脚本中
cd /srv/www/
. scripts/install-functions.sh
#tons of other stuff
cd /srv/www/
. scripts/mage-install.sh in install-functions.sh
install_repo(){
if [ $2 ]
then
echo "just 1"
git clone $1 -q
else
echo "just 1 and 2"
git clone $1 $2 -q
fi
success=$?
if [[ $success -eq 0 ]];
then
echo "Repository successfully cloned."
echo "cleaning"
cd $r/
rm -rf LICENSE.txt STATUS.txt README.md RELEASE_NOTES.txt modman
cd ../
cp -af $r/* .
rm -rf $r/
if [ -z "$3" ]
then
echo "no callback"
else
eval $3
fi
else
echo "Something went wrong!"
fi
sleep 1 # slow it down to insure that we have the items put in place.
}
#declare -A list = ( [repo]=gitUser )
install_repolist(){
gitRepos=$1
for r in "${!gitRepos[@]}" #loop with key as the var
do
giturl="git://github.com/${gitRepos[$r]}/$r.git"
echo "Adding $r From $giturl"
if [ -z "$r" ];
then
echo
else
install_repo $giturl $2 $3
fi
echo
done
return 1
}在脚本/mage-install.sh中
declare -A gitRepos
#[repo]=gitUser
gitRepos=(
[wsu_admin_base]=jeremyBass
[wsu_base_theme]=jeremyBass
[Storeutilities]=jeremyBass
[StructuredData]=jeremyBass
)
cd /srv/www/mage/
install_repolist $gitRepos 0 "php /srv/www/scripts/mage/install-invoke-app.php"
unset gitRepos #unset and re-declare to clear associative arrays
declare -A gitRepos这就是这里的基本循环。我需要回拨一个函数,但是install_repolist也用于其他领域,所以我不能硬编码它。如果还有更好的方法
发布于 2013-09-14 01:41:30
您的脚本中仍有一些部分我不理解,或者不确定它是否有效,但关于您的问题,我认为只有将其放在如下函数上,您的回调才能起作用:
function mycallback {
php /srv/www/scripts/mage/install-invoke-app.php
}并将install_repolist函数调用为
install_repolist $gitRepos 0 mycallback这将使您的php命令调用与文件参数一起工作,但是有一件事:我不认为gitRepos的值实际上可以这样传递。
代码的大多数部分都有实际上需要围绕双引号( "" )引用的变量。它的一个问题是,您的php命令将以一个参数php的形式执行,而不会再以分词的方式执行文件。
https://stackoverflow.com/questions/18797273
复制相似问题