Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run an existing CLI program on a web page

Tags:

php

apache

This must be a solved problem, but Googling hasn't found me an answer.

I have an existing program with an interactive, text-only, command-line interface. I'd like to run this program on a web server so that each session gets a unique session of the CLI program, and each time a command is typed into the web page the corresponding response gets sent back.

I sorta-kinda know how to do this if the program were run fresh each time; what I'm looking for is how to do this so that the program keeps running (presumably in its own process), and the web page gets updates.

It'll be on a Linux box. Security hints would be helpful -- I'm hoping that I can run the program itself as a user that's tailored to have just enough privileges to actually run, but as little as possible otherwise to keep a hacker from getting in.

like image 664
Tim Wescott Avatar asked Oct 20 '25 03:10

Tim Wescott


1 Answers

Try https://seashells.io/

Seashells lets you pipe output from command-line programs to the web in real-time, even without installing any new software on your machine. You can use it to monitor long-running processes like experiments that print progress to the console. You can also use Seashells to share output with friends!

$ echo 'Hello, Seashells!' | nc seashells.io 1337
serving at https://seashells.io/v/{random url}

Other article explaining seashells

Another alternative if you only want to see the result of the command, you can use websocketd

like image 100
Kokizzu Avatar answered Oct 22 '25 19:10

Kokizzu