dongmi1872 2013-07-25 21:32
浏览 43
已采纳

试图通过我的PHP脚本在我的apache服务器中执行bash命令,但是收到错误

i have just started implemting bash commands into my php scripts the first few works fine now i am trying to do the following bash command in my php script

exec("awk -F: '{printf "www.example.com/2/tks.php?account=%s%%3A%s
" ,$1, $2 }' < /opt/lampp/htdocs/$filename > /opt/lampp/htdocs/2.txt");

the error i am getting from my php script that worked fine before i put this in is

Parse error: syntax error, unexpected 'www' (T_STRING) in /opt/lampp/htdocs/index.php on line 54
  • 写回答

2条回答 默认 最新

  • dongmengan8620 2013-07-25 21:33
    关注

    You have to escape your double quotes in the string:

    exec("awk -F: '{printf \"www.example.com/2/tasks.php?account=%s%%3A%s\
    \" ,$1, $2 }' < /opt/lampp/htdocs/$filename > /opt/lampp/htdocs/2.txt");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮