2018-08-16 07:53
浏览 315

我可以从命令行运行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:


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.

图片转代码服务由CSDN问答提供 功能建议

我想使用 shell_exec 来运行 curl 并获取 响应。 问题是我的shell exec命令在运行 curl 时不起作用,当我在 cmd 中运行 curl 时,它工作正常 >或 cygwin 。 我正在使用带有php 7.2的laravel 5.6


< p> shell_exec(“ping”);


但是 我无法运行:

shell_exec(“curl some thing here”);

它 当我使用 dd()时给我 null 或当我 print_r()时给我空白。

    \ n
  • 我的卷曲版本7.61 windows 10 64bit,open ssl 1.1.0i
  • 已在环境中设置路径系统变量


  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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.

    打赏 评论
  • Jason Ho 2021-01-05 14:16

    curl需要完整 的路径,例如你的curl安装在F

    打赏 评论

相关推荐 更多相似问题