elisescu / tty-share

Share your linux or osx terminal over the Internet.
https://tty-share.com/
MIT License
806 stars 87 forks source link

Adding non-interractive option #46

Closed mohzulfikar closed 1 year ago

mohzulfikar commented 2 years ago

Maybe we can create an option so that we can run tty-share without pressing enter? @elisescu @matthewstrasiotto. thank you

antifob commented 2 years ago

Since tty-share provides shell access to the machine on which it runs, requesting user input is quite sensible. If it didn't require user interaction, it would be easy to abuse for malicious purposes.

elisescu commented 2 years ago

I think it might make sense to have a flag like that, but have it default to the current behaviour. I could imagine that it would be useful to not require pressing Enter in certain cases. I may look into it at some point, but I have very little time now. Feel free to push a change with that, if you want , @mohzulfikar :)

artificiel commented 2 years ago

it would be great to also be able to pass a command that is executed, for example setting up a Curses "service" that runs unattended, but available via tty-share.

elisescu commented 2 years ago

If I get what you're saying, @artificiel , then you can already do that with the two flags: --command and --args. Check that out

artificiel commented 2 years ago

yes these flags are great, but hitting Enter is still required, so not possible to spawn unattended.

artificiel commented 2 years ago

to be clear: using something like screen -d -m /path/to/tty-share --command service.sh

strazto commented 2 years ago

not saying this is ideal, but does piping in echo " " | tty-share work to simulate a newline?

artificiel commented 2 years ago

ha! well the echo idea was nice but does not work it say Input not a tty (at least on linux 4.15.0 x86_64)

BUT noodling around the idea led me to tmux which has a send-keys command. so this works:

tmux new-session -d -s tshare tty-share_linux-386 -listen some.host.net:4444 --command /usr/bin/top && tmux send-keys -t tshare: "Enter"

if you want to actually re-attach to the tmux session (so answering the initial request of "not having to press enter") you can append && tmux attach -t tshare: and keep on trucking with the process with the Enter taken care of.

it's quite some funny stuff, thinking about it.

(note: perhaps it would be feasible with screen too but tmux proved more straightforward to harness)

strazto commented 2 years ago

ha! well the echo idea was nice but does not work it say Input not a tty (at least on linux 4.15.0 x86_64)

Tbh I'm not too surprised, as it was kind of a hack anyway. I think the request is valid in any case, wanting to launch non-interactively is a valid requirement sometimes (without needing hacky workarounds like weve described).

strazto commented 2 years ago

https://github.com/elisescu/tty-share/blob/e6bbaefd4708aff17c35aeba7f01c523935b91fb/main.go#L170

Here's the offending line, it could either be removed, or a new option --headless could be given

elisescu commented 1 year ago

@mohzulfikar , @strazto I've added a small change to add that. Have a look: https://github.com/elisescu/tty-share/releases/tag/v2.3.0

As always, any feedback is appreciated.

elisescu commented 1 year ago

Closing this, as --headless is an option with the new version