#!/usr/bin/python import os, time, sys '''Tool to log into the wincable system, first checks if any process is running, if yes, kills it and then invokes the binary client''' #======================================================= #===================== CONFIGURATION =================== CLIENT_DIR = '/home/rutu/crclient' USERNAME = "rushiraj" #======================================================= #======================================================= os.chdir(CLIENT_DIR) def startClient(): stopClient() removeFile() print "Starting client ..." login = "./crclient -u " + USERNAME start = os.popen(login) # start.read() print print def removeFile(): #Forcefully remove pid file if any os.popen("rm -fr /tmp/crclient.pid") def stopClient(): # Check for existing process, if found, terminate, kill p = os.popen("ps ax | grep 'crclient -u' | grep -v grep") pss = p.read() if (pss != ""): # process is running, try to terminate print "Terminating process ..." os.popen("./crclient -l") time.sleep(1) removeFile() #Check first argument command = sys.argv[1] if command == "start": startClient() elif command == "stop": stopClient() # vim: set ft=python: