没有 curl 或 wget 的 HTTP 请求(Ubuntu Core Bash)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48853480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTTP Request Without curl or wget (Ubuntu Core Bash)
提问by Maciek Rek
How do I make a HTTPS (or HTTP) request in Ubuntu Core? The curland wgetare unavailable (and I don't know of any alternatives).
如何在 Ubuntu Core 中发出 HTTPS(或 HTTP)请求?该卷曲和wget的不可用(我不知道任何替代品)。
I am trying to update the DtDns with this line: https://www.dtdns.com/api/autodns.cfm?<options>
我正在尝试使用以下行更新 DtDns: https://www.dtdns.com/api/autodns.cfm?<options>
--
——
Edit
Wasn't able to find any quick'n'easy solution therefore took a longer detour and learned about creating snaps with snapcraft (in classic mode). Then simply included curl in the snap along with my bash script. Here is an excerpt from my snap.yaml:
编辑
无法找到任何快速简便的解决方案,因此走了更长的路,学会了使用 snapcraft(在经典模式下)创建快照。然后简单地将 curl 与我的 bash 脚本一起包含在 snap 中。这是我的 snap.yaml 的摘录:
apps:
my-app:
command: my-app.sh
daemon: simple
restart-condition: always
parts:
client:
plugin: dump
source: my-app-src/
stage-packages:
- curl
A good starting point: How to build a snap – tutorial.
一个好的起点:如何构建快照 - 教程。
回答by Kyle
You should install the classic snap, which allows you to use tools like curl and wget. From the developer tools page:
您应该安装经典 snap,它允许您使用 curl 和 wget 等工具。从开发人员工具页面:
$ snap install classic --edge --devmode
Then get into the classic shell (allowing you to use apt):
然后进入经典shell(允许你使用apt):
$ sudo classic
回答by einpoklum
I'm not 100% sure it's in Ubuntu Core, but a very fundamental and common program is netcat
, for sending arbitrary data over TCP or UDP. See:
我不是 100% 确定它在 Ubuntu Core 中,但一个非常基本和常见的程序是netcat
,用于通过 TCP 或 UDP 发送任意数据。看:
Asking a HTTP GET request with netcat
here on the site.
在网站上。