Show HN: Script-httpd – Turn command line scripts into web services

24 points by beefsack 4 years ago | 10 comments
  • freedomben 4 years ago
    This kind of reminds me of the venerable tool "netcat." Through such simplicity, elegance and power emerge.

    If you've used netcat before you know how useful it can be, but also be very careful ever exposing it to the internet (or even your LAN if there could be malicious users connected).

    • flqn 4 years ago
      Huh, seems like a more convenient CGI
      • gadelat 4 years ago
        Hmm looks similar to stdinho https://github.com/ostrolucky/stdinho. Difference is that script-httpd accepts incoming http data and pipes it to process, returning result. Stdinho does not accept incoming http data, it just takes whatever stdout process returns right as process starts. This allows it to not wait for http connection and start buffering before that.
        • beefsack 4 years ago
          stdinho just reads raw data from stdin, whereas script-httpd proxies to an executable command.
          • gadelat 4 years ago
            That's what I said, right?
        • avmich 4 years ago
          Great.

          Can we use pipes of commands for processing?

          Is it possible to avoid creating processes along the way - to have a sort of precompiled service in memory, waiting for requests?

          • beefsack 4 years ago
            It's possible to use pipes, as well as redirection, but you need to do something like:

            script-httpd bash -c 'some_command | some_other_command 2>&1'

            For having a longer running service in the background it might make more sense to just use something like nginx as a reverse proxy. It is something I've been pondering though.

          • bsg75 4 years ago
            How would this compare to websocketd ?
            • beefsack 4 years ago
              It's very similar to websocketd, however this is intended to be used by one-shot scripts over HTTP.

              websocketd uses the WebSocket protocol for streaming scripts, whereas script-httpd uses plain HTTP for terminating scripts.

            • MuffinFlavored 4 years ago
              pipe incoming request bodies into commands as `stdin`

              very cool. could be pretty useful :)