Python Forum
[inconsistent output] subprocess.call to run cmd commands to get Kerberos ticket
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[inconsistent output] subprocess.call to run cmd commands to get Kerberos ticket
#1
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:
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
Reply


Messages In This Thread
[inconsistent output] subprocess.call to run cmd commands to get Kerberos ticket - by Yelin - Jun-07-2018, 02:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  why is yfinance returning an ellipsis in the middle of ticket history db042190 3 1,009 Jun-12-2023, 06:03 PM
Last Post: db042190
  Read csv file with inconsistent delimiter gracenz 2 1,248 Mar-27-2023, 08:59 PM
Last Post: deanhystad
  merge two csv files into output.csv using Subprocess mg24 9 1,863 Dec-11-2022, 09:58 PM
Last Post: Larz60+
  Inconsistent loop iteration behavior JonWayn 2 1,030 Dec-10-2022, 06:49 AM
Last Post: JonWayn
  ValueError: Found input variables with inconsistent numbers of samples saoko 0 2,512 Jun-16-2022, 06:59 PM
Last Post: saoko
  Loop Dict with inconsistent Keys Personne 1 1,635 Feb-05-2022, 03:19 AM
Last Post: Larz60+
  Inconsistent counting / timing with threading rantwhy 1 1,791 Nov-24-2021, 04:04 AM
Last Post: deanhystad
  Inconsistent behaviour in output - web scraping Steve 6 2,629 Sep-20-2021, 01:54 AM
Last Post: Larz60+
  Found input variables with inconsistent numbers of samples: [1000, 200] jenya56 2 2,948 Sep-15-2021, 12:48 PM
Last Post: jenya56
  Packages inconsistent warning during hdbscan install Led_Zeppelin 0 1,961 Aug-31-2021, 04:10 PM
Last Post: Led_Zeppelin

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020