3 ms·
Disclaimer: I am an idiot on this subject I recently found out that you can’t easily spawn a shell and then send commands to it. It’s doable with tmux commands
by kuwze 8y ago
Disclaimer: I am an idiot on this subject
I recently found out that you can’t easily spawn a shell and then send commands to it. It’s doable with tmux commands, but you’d think it would be easier. I just wanted to write something that locates npm/virtualenv stuff in bash, nothing fancy.
- lanstin 8y agoI think you want expect.
- gavrif 8y agoWhy can't you run a shell script?
- anyfoo 8y ago"expect" was mentioned, but what are you actually trying to do that cannot be solved with a shell script, either executed the normal way or sourced in at the start of a new shell?
- kuwze 8y agowow I feel like an idiot, thank you.
- 0xEFF 8y agoecho ls | bash
- earenndil 8y agoIf you have echo and a pipe, then you're most likely already in a shell, no?
- yjftsjthsd-h 8y agoIt even seems to work with named pipes, although in my first test it exited after the first command (I suspect I'm accidentally sending a EOF when I echo the command in). mkfifo testpipe1 <testpipe1 bash # in separate window echo ls > testpipe1
- adrianmonk 8y agoWhat do you mean by locates?
- Groxx 8y agoJust to join in the "I feel like an idiot" fun: yea, I've used tmux to do this too. First I've heard of `expect`. TIL. Bash is pretty bad at helping you discover how to do things.
- pjc50 8y agoA distinction you may be having trouble with, because it's kind of hidden from the user, is the difference between a shell and a "pty" (pseudo teletype). You certainly can spawn a shell and send it commands, but because it doesn't have a pty the input is treated very differently. That's what you get setup for you by running tmux, screen, expect, xterm, ssh etc. (Bonus: https://askubuntu.com/questions/481906/what-does-tty-stand-for/482244#482244 https://askubuntu.com/questions/481906/what-does-tty-stand-f... )