LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-22-2013, 12:36 PM   #1
sharky
Member
 
Registered: Oct 2002
Posts: 569

Rep: Reputation: 84
execute bash script from pySide script


I wrote a tcltk script that 'catches' stdout from a bash script and saves it to a variable. The proc is executed in the interface with a command button.

Trying to do the same thing in pySide and haven't a clue. I'm a pySide noob and the whole signal/slots things is a foreign language to me at this point.

I'm sure this is documented somewhere and I'm reading stuff but haven't found anything that addresses this particular situation.

If someone has an example, explanation, or tutorial on how to do this it would be appreciated.

Thanks in advance.
 
Old 12-23-2013, 09:54 AM   #2
sharky
Member
 
Registered: Oct 2002
Posts: 569

Original Poster
Rep: Reputation: 84
Made some progress.

First defined a function that calls a bash script. The bash script is stupid simple doing nothing but "cat ~/.bashrc'.

Was able to connect the function to a button. It works. Clicking the button caused by ~/.bashrc file to be returned to the terminal.

This is the python function;

Code:
import sys
import subprocess

def get_quota():
	process = subprocess.call(['/home/me/scripts/pySide/dummy.sh'])
I was expecting that nothing would get returned unless I specifically printed "process".

Is there a way to prevent stdout from returning to the terminal?

Thanks again.
 
Old 12-23-2013, 10:22 AM   #3
sharky
Member
 
Registered: Oct 2002
Posts: 569

Original Poster
Rep: Reputation: 84
Baby steps;

Can now suppress/control the output. The function now looks like this.

Code:
import sys
import subprocess

def get_quota():
	process = subprocess.Popen(['/home/me/scripts/pySide/dummy.sh'], stdout=subprocess.PIPE)
	quotaout = process.communicate()[0]
        print quotaout
The problem now is getting quotaout into the textedit widget.
 
Old 12-23-2013, 01:49 PM   #4
sharky
Member
 
Registered: Oct 2002
Posts: 569

Original Poster
Rep: Reputation: 84
Works now

Moved the function definition into the main window class and called it with 'self' and it works.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute bash script in C waqasdaar Programming 15 10-27-2015 02:54 PM
[SOLVED] execute VI command from bash script goillini Linux - Server 3 07-03-2013 02:45 PM
Can't execute Bash script. zbe Linux - Software 4 10-17-2008 08:05 AM
how to execute bash-script from .bashrc mrsvan Linux - General 3 07-21-2008 07:26 AM
remote execute a bash script vmware Linux - Enterprise 3 09-07-2006 03:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration