我找不到错误,脚本从控制台运行正常,我认为它是PHP的东西,但无法解决任何问题。
也许权限的东西?执行事情?我真的不太了解,希望有人可以帮助我。谢谢!
BASH脚本(简单介绍一个打印机的工作,但我把它放在以防万一):
#!/bin/bash
PBOX_DIR_TMP="/tmp"
DESDE=$1
HASTA=$2
FORMULARIO=$3
COLA=$4
FECHA=$(date +%F)
SPOOL="/spool.$$.txt"
ARCHIVOSALIDA="${PBOX_DIR_TMP}"/salida.$$.txt
RETURNCODE=0
echo "$DESDE"
echo "$HASTA"
echo "@PBSSFORM ${FORMULARIO}" > "${SPOOL}"
for ((i = ${DESDE};i <= ${HASTA};i++))
do
if [ $i > ${DESDE} ]
then
echo -e "\f${FECHA}" >> "${SPOOL}"
echo "${i}" >> "${SPOOL}"
else
echo "${FECHA}" >> "${SPOOL}"
echo "${i}" >> "${SPOOL}"
fi
done
cat "${SPOOL}" | pboxsvc ${PBOX_DIR_BIN}/pboxlib.bin AplicarHostForm > "${ARCHIVOSALIDA}"
lp -d "${COLA}" "${ARCHIVOSALIDA}"
RETURNCODE=$?
rm "${ARCHIVOSALIDA}"
rm "${SPOOL}"
if [ ${RETURNCODE} -eq 0 ]
then
exit 1
else
exit 0
fi
PHP电话:
$cmd = "/printb/imprimirFormPlano.bin 1 2 FILE.PS Cola1";
Apache日志:
/printb/imprimirFormPlano.bin 1: Syntax error: ")" unexpected
sh: 2: not found.
如果我从shell中调用它,脚本可以正常工作:./printb/imprimirFormPlano.bin 1 2 FILE.PS Cola1
答案 0 :(得分:1)
看起来你的apache的默认shell是sh
而不是bash
。尝试将命令更改为
$cmd = '/bin/bash /printb/imprimirFormPlano.bin 1 2 FILE.PS Cola1';