expect

Problem with expect script that deals with multiple processes

The expect script was meant to test a network server. In the script, the server was first started, and then client A and B are started with telnet command. Client A was started before client B. The testing flow is: client A starts, register to the server client B starts, register to the server, send a message to client A client A send ...

dejagnu timeout question

I have two testing script written in dejagnu/expect. When I run any one of them, it is fine. However, when I just call runtest to run both of them. I always get a timeout failure for the second testing script. I wonder if the timeout option in expect works on per expect basis or ...? Anyone can help me? Thank you. ...

expect replacement

I want to work with a modem interfaced on a serial port on an embedded platform. Here are some solutions I have rejected so far : Expect plus a terminal program : My (cross)build system does not have any package rules for expect, and according to the installation instructions from the expect sources, the configure script needs to be i...

How can I flush the input buffer in an expect script?

I'm writing an Expect script and am having trouble dealing with the shell prompt (on Linux). My Expect script spawns rlogin and the remote system is using ksh. The prompt on the remote system contains the current directory followed by " > " (space greater-than space). A script snippet might be: send "some command here\r" expect " > " ...

(Tcl/Expect) clear screen after exit

I want to clear the screen (on the local machine) after exiting from my (semi) interactive expect script. Can I do that from within the script? Here's what I tried, that failed. #!/usr/bin/expect -f set env(TERM) vt100 spawn ssh -Y username@domain set user username set pass password #login sequence expect "password: " send "${pass}\r"...

Expect - get variable from screen region based on row and column

I'm auto-interacting with an SSH session and an ERP program using Expect. Rather than relying on a regular expression to capture a variable in my expect script would it be possible upon receiving a certain keystroke from a user to capture a screen region, say one field, into a variable in the code? Send the server some other commands a...

Where can I find TTY and curses documentation for Unix?

I'm working on automation tools for an ERP program running on SCO Unix. See my questions on Expect: http://stackoverflow.com/questions/1987302/tcl-expect-clear-screen-after-exit http://stackoverflow.com/questions/1988811/expect-get-variable-from-screen-region-based-on-row-and-column Where can I find (either locally or on the web) res...

Regular Expression to find string in Expect buffer

I'm trying to find a regex that works to match a string of escape characters (an Expect response, see this question) and a six digit number (with alpha-numeric first character). Here's the whole string I need to identify: \r\n\u001b[1;14HX76196 Ultimately I need to extract the string: X76196 Here's what I have already: interact...

using python expect to run openvpn

i need a python script to run open vpn automaticaly but i use sudo for run the open vpn sudo openvpn --cd /etc/openvpn --config openvpn.conf & thats my terminal command. i have to give the password for sudo, can i use pexpect to run that command? and i have to get the exit code because i want to know that the openvpn is run succesful...

Cross platform solution for automating ncurses-type telnet sessions

Background Part of my work in networking and telco involves automating telnet sessions when legacy hardware doesn't offer easy solutions in other interfaces. Many older pieces of equipment can only be accessed via craft ports (RS-232 serial ports), SNMP, or telnet. Sometimes telnet is the only way to access specific information, however...

command line connect to tcp port, read data, match pattern, print true or false

I'm trying to write a monitoring script. It should connect to some port on my server. Read the output. If the output is the expected value, print 1, otherwise print 0. I'm working on a solution involving cat < /dev/tcp/hostname/port, but the solution eludes me. Maybe something involving expect? Prefer a bash script solution. Help appreci...

How do you save and parse a command output in Expect?

Hi, I am half-way through writing an Expect script on a Linux server which is supposed to telnet to a router in order to collect some system information. So far my script can successfully make the connection, run a router command, disconnect and terminate. The command displays a few lines which I need to parse, something I am not sure...

Expect-like tool for binary protocol testing

I'd like to write tests for a simple byte-oriented protocol using something like Expect. The test scripts would look like a plain stream of: send "data" expect "data" (Where send writes to stdout and expect reads just enough from stdin, exiting if it doesn't match.) I can't use expect itself because it is designed for buffered, line-...

ncurses - expect: sleep executes at wrong time

I have some ncurses apps that I need to automate to test repeatedly. I am placing the "sleep" command between "send" commands. However, what i see is that all the sleep's are executed in the beginning before the screen loads. expect concatenates the sends (I see that at the screen bottom during sleep) then issues them together. I have t...

cygwin's expect doesn't work with net use?

I need to automate the 'net use' command on cygwin. The command is 'net use /user:"name" \somewhere'. And 'Enter the password for 'name' to connect to 'prosseek':' is expected to enter the password. It works well with command line input, and when run inside batch file. It doesn't work when I make a expect script as follows. spawn net...

how to use a shell script to supply a password when the interface asks for it.

I have a script(dobrt) which upon executing asks for a password.How can i write a script which executes dobrt and automatically supplies the password it asks for. when i execute ./dobrt -p file.txt , the system asks for a password. I want the password to be sent in automatically by the script. Here is the output $ ./dobrt -p file.txt ...

Writing tests that use GDB - how to capture output?

I am trying to write tests that interact with GDB but am having trouble capturing the output. I would like for a log file to be generated which looks like what would have been seen in a terminal had the test been executed by hand. GDB is proving to be very stubborn when it comes to capturing its output however. I've been able to write E...

bash command to repeatedly emulate keypress on a proceess

The nmap tool has such a feature - when you're performing a scan [#nmap -A -T4 localhost] and press "Enter" - it displays kind of status information "Timing: About 6.17% done" Question - how can I force this keypress to happen repeatedly without touching a keyboard in bourne shell? ps: just trying to find a work-around for a bug in php...

Expect script, working for years, behaves unexpectedly with new Expect version

I recently migrated from a FreeBSD 4.x server to a FreeBSD 8.0 server. I am now using expect-5.43.0_3. I don't remember what the old version of expect is, and I can't quickly check, because the hard drive on the old system crashed within minutes of finishing the migration! (WHEW!) Anyway, I have an expect script that creates a zipped...

how to automate the testing of a text based menu

Hi there, I have a text based menu running on a remote Linux host. I am using expect to ssh into this host and would like to figure out how to interact with the menus. Interaction involves arrowing up, down and using the enter and back arrow keys. For example, Disconnect Data Collection > Utilities > Save Changes When you enter the s...