gpt4 book ai didi

java - 能够运行 shell 脚本,但不能运行来自 java 的 Runtime.getRuntime().exec() 的 curl 命令

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:38:55 24 4
gpt4 key购买 nike

我正在尝试通过 java 的运行时从 java 进行 curl POST。当我在其中运行带有命令“curl -vF etc”的 shell 脚本时,代码按预期运行,但如果我尝试将命令作为正确转义的字符串拉入 java,则会出现以下异常/错误“协议(protocol)“libcurlcurl 中不支持或禁用 http””

String cmd = "./go.sh";
Process process = Runtime.getRuntime().exec(cmd);
//etc...

对比

String cmd = "curl -vF etc";//found in go.sh
Process process = Runtime.getRuntime().exec(cmd);
//etc...

输出

"Curl Executed Correctly"
//proprietary

对比

* Protocol "http not supported or disabled in libcurlcurl: (1) Protocol "http not supported or disabled in libcurl

最佳答案

一小段谷歌搜索节目的 this page .这表明您的字符串不正确。

关于java - 能够运行 shell 脚本,但不能运行来自 java 的 Runtime.getRuntime().exec() 的 curl 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10758115/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com