Hotel application
Good Day Everyone,
this place seems to be the best online for asking help related to applescript that I am trying to create. I am sure that this will be easy task for you guys.
I need search option to compare user input and add it into variable. It does not require database, it has to search from simple text file of any format.
it will be used to reboot devices in hotel operations. I have part of code that works, unlucky i dont have enough time to search try and complete it therefore I need your help.
Here is part of working code I have, all what it does reboots unit 172.25.82.48. It sends 4 commands. Dont be confused "yes" is just some input that I need to send after ssh into machine so i can proceed.
Now prior this i need small window that asks user "enter room number:" when user types that example 1234B program should go to txt file and search for that numbers ip address. txt file will be like this:
1234B - 172.25.80.52
1245A - 172.25.17.54
etc....
after it founds room number that user input it has to extract ip address from written next to it and add it in below part of code admin@172.25.82.48
purpose is to reboot devices and make easy interface for user since all ip addresses of devices are static, and if we encounter some changes we can just update that txt file with new IP's
Thank you all !
property commandString : "ssh admin@172.25.82.48"
property commandString1 : "yes"
property commandString2 : "password"
property commandString3 : "sudo reboot now"
property commandString4 : "password"
tell application "Terminal"
launch
set visible of window 1 to false
if (count of windows) is 1 then
do script commandString in window 1
delay 10
do script commandString1 in window 1
delay 5
do script commandString2 in window 1
delay 5
do script commandString3 in window 1
delay 5
do script commandString4 in window 1
else
set frontmost of window 1 to true
do script commandString in window 1
delay 10
do script commandString1 in window 1
delay 5
do script commandString2 in window 1
delay 5
do script commandString3 in window 1
delay 5
do script commandString4 in window 1
end if
end tell
delay 1
tell application "Terminal"
if (count of windows) is 1 then
quit
else
set frontmost of window 1 to true
end if
end tell
tell application "Finder"
display dialog "Device Rebooted"
end tell
Mac mini, OS X Mountain Lion (10.8.1)