doutuo7609 2018-08-16 07:53
浏览 452
已采纳

我可以从命令行运行curl但不能从shell exec调用

I want to use shell_exec to run curl and get the response. The problem is that my shell exec command doesn't work when I run curl, it works fine when I run curl in cmd or cygwin. I'm using laravel 5.6 with php 7.2

I can run:

shell_exec("ping domain.com");

It return response like it has used to.

But I can't run:

shell_exec("curl some thing here");

It gives me null when I use dd() or blank when I print_r().

  • My curl version 7.61 windows 10 64bit, open ssl 1.1.0i
  • Already set path system variable on environment

I know I can use guzzle, but I am just wondering why it doesn't work.

  • 写回答

2条回答 默认 最新

  • dourang6858 2018-08-16 08:10
    关注

    Consider using PHP Curl (IT's necessary to enable PHP curl extension). It's a safer way - You dont need to access shell + on many shared hostings, it's disabled - and also works natively under Windows.

    The problem you are fighting off is caused probably by missing PATH. That's why it works in cygwin, not under native shell. Note that PHP execs in native shell.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 cplex运行后参数报错是为什么
  • ¥15 之前不小心删了pycharm的文件,后面重新安装之后软件打不开了
  • ¥15 vue3获取动态宽度,刷新后动态宽度值为0
  • ¥15 升腾威讯云桌面V2.0.0摄像头问题
  • ¥15 关于Python的会计设计
  • ¥15 聚类分析 设计k-均值算法分类器,对一组二维模式向量进行分类。
  • ¥15 stm32c8t6工程,使用hal库
  • ¥15 找能接spark如图片的,可议价
  • ¥15 关于#单片机#的问题,请各位专家解答!
  • ¥15 博通raid 的写入速度很高也很低