Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 159

Run an os.popen command requiring pseudo terminal from python in bash script

$
0
0

I have a python script which uses

size = os.popen('stty size', 'r').read().split()

to get the terminal window size so I can print text nicely. My problem arises when I have to run this python script through a bash script. I have a bash script which calls rosrun on this python script in the background (using &), and I get the error -

stty: 'standard input': Inappropriate ioctl for device

After looking around a bit, I understand this is because stty requires a terminal (or pseudo-terminal) and the bash script I am running is not providing it. I cannot use sudo as ros commands cannot be run with root user.

Using script -q -c command doesn't help either. Is there some way that I can fix this issue without having to change os.popen command in the python script to an alternative? Currently, I am thinking of perhaps adding a print before the os.popen and using expect in the bash script.


Viewing all articles
Browse latest Browse all 159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>