Jun-07-2018, 02:58 PM
As part of my daily work, I need to run a couple of lines of commands in cmd prompt in order to get Kerberos ticket to a database. Here are the commands:
cd C:\ProgramData\MIT\Kerberos5\
"C:\Program Files\MIT\Kerberos\bin\kinit" -kt ossuser.keytab ossuser
I am now asked to make it more nicely, i.e., by making it as a button on a GUI (which contains many other function) developed using Tkinter. To do this, I try to use subprocess.call. Here are the commands:
Command_piece_1:
And here is my definition for the button before root = Tk():
Command_piece_2
Anyone knows how this can happen? Do I miss out something in the function definition?
Python version: 3.6.2
Tk version: 8.6.6
IDLE version: 3.6.2
cd C:\ProgramData\MIT\Kerberos5\
"C:\Program Files\MIT\Kerberos\bin\kinit" -kt ossuser.keytab ossuser
I am now asked to make it more nicely, i.e., by making it as a button on a GUI (which contains many other function) developed using Tkinter. To do this, I try to use subprocess.call. Here are the commands:
Command_piece_1:
import subprocess command_01='cd C:\ProgramData\MIT\Kerberos5' command_02='"'+'C:\Program Files\MIT\Kerberos'+'\\'+'bin\kinit'+'"'+' -kt ossuser.keytab ossuser' conn=subprocess.call(command_01+"&"+command_02, shell=True)
And here is my definition for the button before root = Tk():
Command_piece_2
import subprocess def connect_impala(): command_01='cd C:\ProgramData\MIT\Kerberos5' command_02='"'+'C:\Program Files\MIT\Kerberos'+'\\'+'bin\kinit'+'"'+' -kt ossuser.keytab ossuser' conn=subprocess.call(command_01+"&"+command_02, shell=True) if conn==0: messagebox.showinfo("INFO","Getting ticket successful.\nYou can close this INFO window.") else: messagebox.showerror("ERROR","Getting ticket failed!\nPlease check if your VPN is working properly and try again.")Now strange thing happens. When I click the corresponding button on the GUI, it fails forever (showing the ERROR window I defined). However, when I try Command_piece_1 in IDLE, it succeeds.
Anyone knows how this can happen? Do I miss out something in the function definition?
Python version: 3.6.2
Tk version: 8.6.6
IDLE version: 3.6.2