

Command Execution › Run Telnet Script Operator › Example
Example
The following procedure provides an example of how to use the Run Telnet Script operator.
- The Run Telnet Script operator reads the login information you specify. The operator uses this login information to connect to the remote Telnet host and to create the "conn" object. The following Remote Login Information example shows typical entries:

- You specify the following in the Script palette:
In this example, the following output variable names are saved to the dataset of the operator at the end of execution: 'svrDate', 'loginStr', 'pwdStr', and 'promptStr'.

- In the Inline script, you can leverage the 'conn' object, built by CA Process Automation. How you can leverage the 'conn' object is shown in the following bean shell script example:

- Create the svrDate, loginStr, pwdStr, and promptStr variables to be visible at the script scope, so they can be saved to the operator’s dataset at the end of execution.
- Use ‘conn.waitFor()’ to wait for the login prompt, “.*ogin: ” (Reg Ex) up to 10 seconds.
- If the login prompt is found within 10 seconds, then use ‘conn.getLastOutput()' to save the login prompt that was matched in the loginStr variable.
- Use ‘conn.sendLine()’ to send the username passed as the first object in the list of parameters: args[0].
- Use ‘conn.waitFor()’ to wait for the password prompt “.*assword: ” (Reg Ex) up to 10 seconds
- If the password prompt is found within 10 seconds, then use ‘conn.getLastOutput()’ to save the password prompt we matched in the pwdStr variable.
- Use ‘conn.sendLine()’ to send the password passed as the second object in the list of parameters: args[1].
- Use ‘conn.waitFor()’ to wait for the user prompt “.*[$] ” (Reg Ex) up to 15 seconds.
- If the user prompt is found within 15 seconds, then use ‘conn.getLastOutput()’ to save the user prompt we matched in the promptStr variable.
- Use ‘conn.sendLine()’ to send the command passed as the third object in the list of parameters: args[2].
- Use ‘conn.waitFor()’ to wait for the user prompt “.*[$] ” (Reg Ex) up to 10 seconds.
- If the user prompt is found within 10 seconds, then use ‘conn.getLastOutput()’ to save the matched user prompt with the output of the command in the svrDate variable.
- At the end of execution, the Run Telnet Script operator saves the output variables in the dataset of the operator as CA Process Automation objects.
The prompt that was matched appears in the output returned by conn.getLastOutput().
Copyright © 2014 CA.
All rights reserved.
 
|
|