HTTP Request Without curl or wget (Ubuntu Core Bash)

14,380

Solution 1

You should install the classic snap, which allows you to use tools like curl and wget. From the developer tools page:

$ snap install classic --edge --devmode

Then get into the classic shell (allowing you to use apt):

$ sudo classic

Solution 2

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:

Asking a HTTP GET request with netcat

here on the site.

Share:
14,380

Related videos on Youtube

Maciek Rek
Author by

Maciek Rek

Helps organisations thrive by creating purpose-centric graphics and easy to navigate websites.

Updated on June 04, 2022

Comments

  • Maciek Rek
    Maciek Rek almost 2 years

    How do I make a HTTPS (or HTTP) request in Ubuntu Core? The curl and wget are unavailable (and I don't know of any alternatives).

    I am trying to update the DtDns with this line: 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:

    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.

    • Maciek Rek
      Maciek Rek about 6 years
      einpoklum's answer pointed me in the right direction pretty much, thank you.
  • Maciek Rek
    Maciek Rek about 6 years
    Yes, the nc exist in Core though I'm struggling with the syntax of the multiline request in my script lol, thanks
  • Florian Heigl
    Florian Heigl almost 4 years
    how true are the warnings that the snap will break security provisions of the normal system?
  • Maciek Rek
    Maciek Rek almost 4 years
    Yes you can but... one of the reasons I went for Ubuntu Core was security, so running the device in the classic mode wouldn’t make much sense as it is much easier to just use a more ‘normal' os with apt-get and so on, such as Ubuntu Server. I understand classic mode is meant for development.
  • kyrofa
    kyrofa almost 4 years
    The classic snap is essentially a chroot. It does include all sorts of software you wouldn't want on a production device, but once you remove it it's gone. It doesn't make system-wide modifications to the length of my knowledge.