1

I want the commands that run a python file with console are in an independent window

my code:

def update(self):
 self.prombt("sh /usr/script/update.sh")
 self.close(None)
 def prombt(self, com):
 self.session.open(Console,_("sTaRt ShElL cOm: %s") % (com), ["%s" % com])

it's possible?

Tank's

asked Apr 26, 2016 at 16:09
1
  • Not entirely sure what you're asking. Perhaps you're looking for the subprocess module? Commented Apr 26, 2016 at 16:21

2 Answers 2

1

You can realize this using the subprocess module.

import subprocess
subprocess.call(["gnome-terminal", "-x", "sh", "/usr/script/update.sh"])

In this example I used "gnome-terminal" as my terminal emulator. On your system you may not have this emulator and you should replace it with the one you use (e.g. Konsole for KDE). You must then also find the appropriate parameter (in this case "-x") to execute the command, when opening the emulator.

answered Apr 26, 2016 at 16:24
Sign up to request clarification or add additional context in comments.

Comments

0

To accomplish this, you can use either subprocess or os.system().

Whichever one you use, the bash command to do so would be:

gnome-terminal -e sh /usr/script/update.sh

for subprocess:

import subprocess
subprocess.call(["gnome-terminal", "-x", "sh", "/usr/script/update.sh"])

for 'os.system()'

import os
os.system("gnome-terminal -e "sh /usr/script/update.sh"")

It is recommended you use subprocess.call() for anything more complex than simple commands as os.system() is outdated.

answered Apr 26, 2016 at 16:29

4 Comments

i use, enigma2 , on box, this plugin for E2
no work.. code def update(self): os.system("gnome-terminal -e sh /usr/script/update.sh")
This.. not work.. def update(self): subprocess.call(["/bin/sh", "sh", "/script/update.sh"]) self.close(None)
@paolozanone im not sure why. however, that is not the subprocess command I recommended.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.