#!/usr/bin/python ''' Created on April 25, 2025 @author: Hovanes Egiyan ''' import os, sys, time, getpass def restartProcServ( host, port ) : """ Function to restart the process running inside procServ """ """ Telnets to the procServ on localhost and type CtrlX to restart the IOC process """ # Username is supposed to be able to login without password username = getpass.getuser() telnetCommand = 'ssh {0}@{1}'.format( username, host ) procServCommand = '( echo -e \\\\0030; sleep 1 ) | telnet localhost {0}'.format( port ) command = telnetCommand + " '" + procServCommand + "'" print 'Will execute command <{0}>'.format( command ) os.system( command ); return if __name__ == '__main__': args = sys.argv[1:] # Make sure only one command line argument exists" if( len(args) != 1 ) : raise Exception("Need one and only one string argument to specify the host for alarm services") host = args[0] # Restart alarm server port = 25040 print "Host is {0}, port number is {1}".format(host, port) restartProcServ( host, port ) time.sleep(20) # Restart alarm notifier port = 25041 print "Host is {0}, port number is {1}".format(host, port) restartProcServ( host, port )