Question:
I am trying to run two commands in a remote terminal session on unix. I want to do: script text.txt > /dev/pts/5 python program.py?
Alex
2015-01-14 14:12:43 UTC
The problem is that when starting script, my local terminal (/dev/pts/4 or whichever number) runs the script command and I am not able to send the python command. Ultimately, I want to have a couple of commands after the script command to be run and everything to be called up by a shell script file.
Three answers:
?
2015-01-14 15:28:44 UTC
I'm a little confused about what you mean by remote.

It looks like you are trying to run "script text.txt" and redirect stdout to /dev/pts/5 which would be a local virtual terminal.

Do you want to run these sequentially?

You could try a pipe like:

script text.txt > /dev/pts/5 | python program.py > /dev/pts/5

Since > sends script text.txt stdout to /dev/pts/5 there shouldn't be anything on python program.py stdin.



BTW: When you say "remote" I think you are trying to run these commands on a different system. In that case, you probably want to use ssh.
Alex
2015-02-12 11:34:24 UTC
So I was confused on using ">"...I thought it would execute the command in the external terminal window, but I was incorrect. I ended up modifying my program.py to tee it's print statements to stdio as well as a text file instead of using "script" command.
Greywolf
2015-01-14 14:14:26 UTC
If you want to enter them both on the same command line, put a & between the two commands.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...