Expect Script - Need help to find solution


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect Script - Need help to find solution
# 1  
Old 03-16-2010
PHP Expect Script - Need help to find solution

I am facing below issue with my script. below is one of the test out of 50 test from the tool which i m trying to automate. the test may show up or may not depending upon the previous results and also from the test some inputs may be asked or may not be asked depending upon previous results so you can assume 40% of input are volatile?

Code:
#Checking Hist_DB_Connectivity
expect  "Enter Historical database user name (*): "
send "dbuser\r"
expect  "Enter password (*):*"
send "dbuser\r"
expect  "Choice 1 or 2 (*):"
send "1\r"
expect  "Enter the host name or IP address (*):"
send "dbhost1\r"
expect  "Enter the port number:  (1521):"
send "1521\r"
expect  "Enter database service name (*):"
send "instance1\r"
expect  { 
"Enter e to execute again or press Enter to continue"
        { send "\r" ; exp_continue}
}

the tool checks for 56 test and some test may show up and may not depending upon previous result is pass or fail so i am using expect as
Code:
expect  { 
"Enter e to execute again or press Enter to continue"
        { send "\r" ; exp_continue}
}

is this a right way to enter the input only if this shown while executing tool on some of the test this script is failing and i tried to debug but it has so much information that i m not able to understand why its getting time out and expect sending the inputs even if that is not matching with why i quoted to matched?

Last edited by pludi; 03-16-2010 at 11:40 AM.. Reason: code tags, please...
# 2  
Old 03-16-2010
Hi,

I feel its the right way as long as it works. You have to manually figure out all the possibilities before you can actually put expect to work on that otherwise you are sure to get unexpected results.

I have worked with expect a lot and at times it can get real slow and troublesome. But thats the way it works.

Regards,
Gaurav.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Expect script returning string following a found expect.

I'm fairly new to scripting so this might not be possible. I am using Expect with Cisco switches and need to capture the string after finding the expect request. For example, when I issue "show version" on a Nexus switch, I'm looking to capture the current firmware version: #show version ... (0 Replies)
Discussion started by: IBGaryA
0 Replies

2. Programming

Calling another expect script inside an expect script

I have an expect script called remote that I want to call from inside my expect script called sudoers.push, here is the code that is causing me issues: set REMOTE "/root/scripts/remote" ... log_user 1 send_user "Executing remote script as $user...\n" send_user "Command to execute is: $REMOTE... (1 Reply)
Discussion started by: brettski
1 Replies

3. Shell Programming and Scripting

Help me to find a solution using UNIX commands

I have the below requirement. below is the content of the input file and my expected result Input file: a.txt <?xml version="1.0" encoding="UTF-8"?> <Employee> <Name>XXXX</Name> <ID>1233</ID> </Employee> <?xml version="1.0" encoding="UTF-8"?> <Employee> <Name>YYYY</Name> <ID>1345</ID>... (2 Replies)
Discussion started by: kmanivan82
2 Replies

4. Programming

Calling expect script inside another expect

Hi, Am very new to expect scripting.. Can You please suggest me how to call an expect script inside another expect script.. I tried with spawn /usr/bin/ksh send "expect main.exp\r" expect $root_prompt and spawn /usr/bin/ksh send "main.exp\r" expect $root_prompt Both... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies

5. Red Hat

alias ip problem,i canīt find out solution

hi, we have eth1; in the beginning it was proposed to create from eth1, eth1.2500 and eth1.240. It did not worked cause vlan 1.2500 was not tagged in the switch. so they decided to leave eth1 like a physical interface with eth1.2500 config (removel vlan tag) and create eth1.240 but it did... (0 Replies)
Discussion started by: pabloli150
0 Replies

6. Shell Programming and Scripting

Please can you help me find a solution in this program in unix ?

Write shell script to read 3 numbers and print them in revers and print wither they are polyndrome numbers or not ????? (2 Replies)
Discussion started by: lovelorn_mn
2 Replies

7. Shell Programming and Scripting

Need help with Expect script for Cisco IPS Sensors, Expect sleep and quoting

This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Discussion started by: genewolfe
1 Replies

8. Shell Programming and Scripting

strange expect script behavior, or am i misunderstanding expect scripting?

Hello to all...this is my first post (so please go easy). :) I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
Discussion started by: v1k0d3n
2 Replies
Login or Register to Ask a Question