0

我找不到错误,脚本从控制台运行良好,我认为这是 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";

阿帕奇日志:

/printb/imprimirFormPlano.bin 1: Syntax error: ")" unexpected
sh: 2: not found.

如果我像这样从 shell 调用它,这些脚本就可以工作:./printb/imprimirFormPlano.bin 1 2 FILE.PS Cola1

4

1 回答 1

1

看起来您的 apache 的默认 shell 是sh而不是bash. 尝试将您的命令更改为

$cmd = '/bin/bash /printb/imprimirFormPlano.bin 1 2 FILE.PS Cola1';
于 2012-12-13T16:27:29.730 回答