Sign in to follow this  
Followers 0
ramanaindia

Expect Like Functionality

3 posts in this topic

Hi Guys

First I want to thank god for this wonder full scripting engine that made my life lot easier

Also I highly appreciate the amount of help and knowledge available at this wonderful forum, kudos and keep up the good work

I am trying to automate all our text based test scripts into one single interface,

the Idea is to have a single GUI

Now you press a button then it will run some scripts in cygwin or in a ssh session and so on

having said that I have written lot of tcl scripts with expect functionality

for example look at the following code

spawn bash; opens a bash shell
expect "#"; expects a #
send "cat log.txt\r"; cat log.txt assume that log.txt has a string "Voila"

expect "Voila"; look for Voila after cat
puts "Found Voila\r"

That's the functionality I am looking for in autoit

Now the issue in question

I am running some scripts in cygwin, i am successful up to the point were I can run the command

for example here is the autoit script

Case $nMsg = $RunAll
            ;MsgBox(0,"title",$cdir)
            Run ($cdir) ; $cdir is the cygwin batch directory
            WinWait("~","")
            If Not WinActive("~","") Then WinActivate("~","")
            WinWaitActive("~","")
            Send("cd c:")
            Send("{ENTER}")
            Send ("cd " & $gdir)
            Send("{ENTER}")
            Send ("./run_sn_reset")
            Send("{ENTER}")

as you can see I am passing the ./run_sn_reset command, if that command is successful then I should see the following message on the cygwin window

Ignoring packet error, continuing...

0xfffffffffe400008 in ?? ()

Ignoring packet error, continuing...

then it will return to the pwd in this case

/cygdrive/c/asic_test/test_gdb/test_gdb_rev1.2

now the question is

How do i look/expect or wait for the string "0xfffffffffe400008 in ?? ()" generated after i run a particular script?

I want to pass or fail depending upon the message I get after I execute the script

also I got analyze a log file created by another script, but that is later, one step at a time

I am attaching the entire code just in case

I appreciate any help on this issue

Regards

ramana

Share this post


Link to post
Share on other sites



I am running some scripts in cygwin, i am successful up to the point were I can run the command

for example here is the autoit script

Case $nMsg = $RunAll
            ;MsgBox(0,"title",$cdir)
            Run ($cdir) ; $cdir is the cygwin batch directory
            WinWait("~","")
            If Not WinActive("~","") Then WinActivate("~","")
            WinWaitActive("~","")
            Send("cd c:")
            Send("{ENTER}")
            Send ("cd " & $gdir)
            Send("{ENTER}")
            Send ("./run_sn_reset")
            Send("{ENTER}")

as you can see I am passing the ./run_sn_reset command, if that command is successful then I should see the following message on the cygwin window

Ignoring packet error, continuing...

0xfffffffffe400008 in ?? ()

Ignoring packet error, continuing...

then it will return to the pwd in this case

/cygdrive/c/asic_test/test_gdb/test_gdb_rev1.2

now the question is

How do i look/expect or wait for the string "0xfffffffffe400008 in ?? ()" generated after i run a particular script?

Welcome to the forum. I think it will be difficult to help you out with this as not many people have access to the same setup that you have, especially cygwin. If possible, can you post an example that can be run on a standard WinXP machine? It will probably allow us to get a better feel for what you are needing and respond appropriately.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Hi Paul

Thanks for the reply here is an example scenario

#include <GUIConstants.au3>


Run("cmd.exe", @SystemDir)
WinWaitActive("C:\WINDOWS\system32\cmd.exe")
Send("ipconfig/all" & "{ENTER}")

Consider the above code, it just opens a dos window and executes the command ipconfig/all and the messages I might get on the dos window might look like

Windows IP Configuration

Host Name . . . . . . . . . . . . : xxxx-xx9x16

Primary Dns Suffix . . . . . . . :

Node Type . . . . . . . . . . . . : Unknown

IP Routing Enabled. . . . . . . . : No

WINS Proxy Enabled. . . . . . . . : No

DNS Suffix Search List. . . . . . : gotdns.org

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :

Description . . . . . . . . . . . : Broadcom 440x 10/100 Integrated Con

roller

Physical Address. . . . . . . . . : xx-xx-xx-xx-xx

Dhcp Enabled. . . . . . . . . . . : Yes

Autoconfiguration Enabled . . . . : Yes

IP Address. . . . . . . . . . . . : 192.xxx.xx.x

Subnet Mask . . . . . . . . . . . : 255.255.255.0

Default Gateway . . . . . . . . . : 192.xxx.x.x

DHCP Server . . . . . . . . . . . : 192.168.1.1

DNS Servers . . . . . . . . . . . : 192.168.1.1

Lease Obtained. . . . . . . . . . : Monday, March 12, 2007 10:32:03 PM

Lease Expires . . . . . . . . . . : Monday, March 19, 2007 10:32:03 PM

Now I am looking for the string "Subnet Mask" and How do I know I get that particular string?

(In this case I am sure that the string "Subnet Mask" will be returned consistently on all the times when the command is executed)

Or How can I assign the stdout on the screen to a variable and then search for that particular string.

I played with stdreadout and It was not successful for example

something similar to the following code, But with no success

$iPID = Run(@Comspec & 'Whatever')

$sGather = ''

While Not @error

$sGather &= stdOutRead($iPID)

WEnd

MsgBox(64, 'Info', $sGather)

your help is greatly appreciated

regards

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0