Você está na página 1de 2

Automating Tasks -such as Siebel Environment Management - using AutoITScript

All Siebel developers and Siebel administrators have to implement repetitive process which can
be mundane and take a lot of time. This article shows how it is possible to automate tasks within
windows to make things easier.

Have a think about what repetitive things do you do on a regular basis as part of your Siebel
Development/Administration???

I work on a Windows XP machine but Siebel is installed on unix. Therefore if I need to login to
all Siebel servers through the back end, I have to log into putty and then run a login script etc.

Why not automate the login to putty process? So that you can run a batch file and putty opens
and anything that needs to be run is run before your eyes!?

AutoITScript is perfect for purposes such as this. And the biggest benefit is that it is FREE!
AutoITScript provides a scripting framework whereby you can create a script to control
windows, send keystrokes, copy text, read text from windows, read the name of a window,
change the name of a window etc.

Here is a quick example of an autoit script to invoke putty and run some commands.

Once you have installed AutoItScript on your computer, create a new .au3 file (test.au3) with the
following detail. This code will:

1. Receive 3 command line inputs (the putty session name, the putty session username, and the
putty session password)
2. Open putty for the session provided as input
3. Wait for 2.5 seconds
4. Check if a window exists with Title: PuTTY Error then exit the script
5. Wait for the PuTTY window to become active
6. Change the title of the PuTTY window
7. Then send key strokes to the putty window as such:
. ./.profile (hit enter)
ls -lrt (hit enter)
8. Then message box is displayed.

1: AutoItSetOption("WinTitleMatchMode", 2)
2:  
3: If $CmdLine[0] < 3 Then
4: MsgBox(1, "error", "error: usage")
5: Exit
6: EndIf
7:  
8: $strSession = $CmdLine[1]
9: $strUname = $CmdLine[2]
10: $strPswd = $CmdLine[3]
11:  
12: $strCmd = 'putty.exe -load ' & $strSession & ' -l ' & $strUname
& ' -pw ' & $strPswd
13:  
14: Run(@ComSpec & " /c " & $strCmd, "", @SW_HIDE)
15:  
16: Sleep(2500)
17:  
18: If WinExists("PuTTY Error") Then
19: Exit
20: EndIf
21:  
22: WinWaitActive("PuTTY")
23: $strSessionTitle = WinGetTitle("")
24: WinSetTitle($strSessionTitle, "", $strSession & " - I have
changed the window text!")
25:  
26: Send(". ./.profile{ENTER}")
27: Send("ls -lrt{ENTER}")
28:  
29: MsgBox(1, "Finished", "I have finished now!")
30:  
31: Exit

Once you have created the above .au3 script, you then compile the script into an executable
(test.exe). Then you would execute the executable through windows command line as such:

test.exe MySavedPuttySession MyUsername MyPassword

Where:
MySavedPuttySesssion = The saved putty session to log into
MyUsername = The username of the putty session
MyPassword = The password of the putty session

Happy automating!

Você também pode gostar