I have the following script in Python :
import Tkinter
import subprocess
from Tkinter import *
top = Tkinter.Tk()
top.geometry( "800x600" )
def helloCallBack():
#print "Below is the output from the shell script in terminal"
text = Text( top )
text.insert( INSERT, "*****************************************************\n" )
text.insert( INSERT, "Below is the output from the shell script in terminal\n" )
text.insert( INSERT, "*****************************************************\n" )
p = subprocess.Popen( './secho.sh', \
stdout = subprocess.PIPE, \
stderr = subprocess.PIPE, \
shell = True \
)
output, errors = p.communicate()
#--------------------------------------------------- DEBUG FRAMING STEP 1
print "DEBUG [stdout] sent:", repr( output ), "<EoString>"
print "DEBUG [stderr] sent:", repr( errors ), "<EoString>"
#--------------------------------------------------- DEBUG FRAMING STEP 2
text.insert( "end", "DEBUG-prefix-to-validate-Tkinter-action.<BoString>" \
+ output \
+ "<EoString>" \
)
text.pack()
#--------------------------------------------------- DEBUG FRAMING STEP 3
print "DEBUG FRAMING <EoCall>"
B = Tkinter.Button( top, text ="Hello", command = helloCallBack )
B.pack()
top.mainloop()
When my shell script which is secho.sh has some simple commands such as ls, the program outputs normally as in the below screenshot. (I could not uplaod an image here as I am a newbee to stack overflow)
http://tinyurl.com/tkinterout
Where as if I have some complex shell script, even if it is a one liner such as :
mail -f ~/Desktop/Test/Inbox.mbox
The display is just the text "Below is the output ...." and nothing else.
I have referred to this, this and many other stack overflow posts related to the same. But I could not get a satisfactory answer as none I found deals with commands such as mail ( which lets the user to interact with the terminal after executing the command).
How to tackle this problem?