Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Pipe bash script to terminal from Python

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
Pybash
Posts: 8
Joined: 2018-02-10 12:04

Pipe bash script to terminal from Python

#1 Post by Pybash »

Hello, I have written a bash script, which runs (almost) fine,
when I call it from terminal emulator like:

Code: Select all

 ~/script.sh
Then I have created a shortcut in Python to pipe the script to a specific terminal emulator.

Code: Select all

Key([Super], "m", lazy.spawn("/home/"+USER+"/.user/init.sh")),]
The init.sh is:

Code: Select all

 ~/script.sh > /dev/pts/0
Now I does not work correctly anymore, it gets interpreted like:

Code: Select all

sh  ~/script.sh > /dev/pts/0
How do I need to call it the right way?

Regards Pb

User avatar
ruwolf
Posts: 623
Joined: 2008-02-18 05:04
Location: Banovce nad Bebravou
Has thanked: 35 times
Been thanked: 26 times

Re: Pipe bash script to terminal from Python

#2 Post by ruwolf »

Does enclosing in parenthesis not help? I do not know, I only guess. :-)

tyler2016
Posts: 5
Joined: 2019-02-07 14:32

Re: Pipe bash script to terminal from Python

#3 Post by tyler2016 »

Is there some reason you can't use os.system() or subprocess?

Code: Select all

$ cat test.bash 
#!/bin/bash

echo hi
tyler@desktop:~$ python
Python 2.7.13 (default, Sep 26 2018, 18:42:22) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.system("/tmp/test.bash")
hi
0
>>> 

Post Reply