Pipe bash script to terminal from Python

Need help with C, C++, perl, python, etc?

Pipe bash script to terminal from Python

Postby Pybash » 2018-02-10 12:16

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
Pybash
 
Posts: 8
Joined: 2018-02-10 12:04

Re: Pipe bash script to terminal from Python

Postby ruwolf » 2019-01-28 02:15

Does enclosing in parenthesis not help? I do not know, I only guess. :-)
User avatar
ruwolf
 
Posts: 365
Joined: 2008-02-18 05:04
Location: Slovakia, Banovce nad Bebravou, Matice slovenskej 1260/4-7

Re: Pipe bash script to terminal from Python

Postby tyler2016 » 2019-02-28 18:24

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
>>>
tyler2016
 
Posts: 5
Joined: 2019-02-07 14:32


Return to Programming

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable