dongshao8125 2012-11-04 15:17
浏览 60

使用cli args调用php脚本的bash脚本

I need to write a bash script that wraps a php script, I have some variables that needs to be forwarded to the php script and some variables that I need internally for the bash script it self.

The call for the shell script should look like that but the php file can have more params so it needs to be generic :

bash  /tmp/test.sh -c -l /tmp/aaa -php aaa.php -d -p 3 -f 2012-10-23

the -php option is mandatory because it contains the php file that needs to be called the -c and -l are optional flag and needs to be used internally for the bash script, everything after the aaa.php are params for the php file.

  • 写回答

1条回答 默认 最新

  • doujiabing1228 2012-11-04 15:41
    关注

    bash /tmp/test.sh -c -l /tmp/aaa -php "aaa.php -d -p 3 -f 2012-10-23" ?

    Don't know how you are passing anythin inside bash script, bu basically everything wrapped in apostrophes is treated as one argument in bash script, passed further to php interpreter is seen as separated parameters, unless of course you don't wrap it again.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分