I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place.
What I need
The following command is placed at the prompt:
TICLI "op:alarm,all" | grep BATT >> outagereport
If there is no alarm that matches BATT
, I still want a title to append to the outagereport
vi file. Such as, Zero Battery Alarms
How can this be done?
Python
of script so far:
# $language = "python"
# $interface = "1.0"
def Main():
crt.Screen.Synchronous = True
crt.Screen.Send("ls" + chr(13))
crt.Screen.WaitForString("hostname> ")
crt.Screen.Send("rm outagereport" + chr(13))
crt.Screen.WaitForString("hostname> ")
crt.Screen.Send("TICLI " + chr(34) + "op:alarm,all" + chr(34) + " " + chr(124) + " grep BATT >> outagereport " + chr(13))
crt.Screen.WaitForString("hostname> ")
crt.Screen.Send(chr(13))
crt.Screen.WaitForString("hostname> ")
crt.Screen.Send("TICLI " + chr(34) + "op:alarm,all" + chr(34) + " " + chr(124) + " grep COMM >> outagereport " + chr(13))
crt.Screen.WaitForString("hostname> ")
crt.Screen.Send("TICLI " + chr(34) + "op:alarm,all" + chr(34) + " " + chr(124) + " grep GEN " + chr(124) + " grep FAIL >> outagereport " + chr(13))
crt.Screen.WaitForString("hostname> ")
crt.Screen.Send("TICLI " + chr(34) + "OP:CELL, OOS" + chr(34) + " " + chr(124) + " grep INDT >> outagereport " + chr(13))
crt.Screen.Send(chr(13))
crt.Screen.WaitForString("hostname> ")
crt.Screen.Send("ls" + chr(13))
crt.Screen.WaitForString("hostname> ")
crt.Screen.Send("cat outagereport" + chr(13))
Main()