expect

Using 'expect' to automatically send in password

I am trying to copy a file from my remote server to my local. Here's my script to run it, by using 'expect' to automaticlally send in password scp user@host:/folder/myFile ./ expect "Password: " send "myPassword" When I run this, it still prompts for "Password", what is wrong? ...

When to Expect and When to Stub?

I use NMock2, and I've drafted the following NMock classes to represent some common mock framework concepts: Expect: this specifies what a mocked method should return and says that the call must occur or the test fails (when accompanied by a call to VerifyAllExpectationsHaveBeenMet()). Stub: this specifies what a mocked method should r...

Expectation on Mock Object doesn't seem to be met (Moq)

I'm experiencing some odd behavior in Moq - despite the fact that I setup a mock object to act a certain way, and then call the method in the exact same way in the object I'm testing, it reacts as if the method was never called. I have the following controller action that I'm trying to test: public ActionResult Search(string query, boo...

Expect-like tool for windows

I am searching for a tool that behaves similarly to Unix's expect tool (or at least, its main function). I want to automate command-line interactive programs with it. EDIT: I am preferring single executables or small apps without big multi megabyte depencies. Ty. ...

Java TelnetClient hangs at “press any key to continue”

I have a Java program that runs on Linux and telnets into a remote server using org.apache.commons.net.telnet.TelnetClient and performs a few commands. The problem is that it hangs intermittently when it gets to an output display that asks the users to “press any key to continue…” The program hangs on this about 1 out of every 10 tims ...

Exit status code for Expect script called from Bash

I made a Bash script which uses an expect script to automate ssh logins.The script connects to multiple servers and runs some commands. The bash script prompts for login credentials once. I want to incorporate a feature wherein the script terminates if the login fails for the first server to avoid the script checking for next servers re...

How can I use Expect to enter a password for a Perl script?

I wish to automatically enter a password while running an install script. I have invoked the install script using the backticks in Perl. Now my issue is how do I enter that password using expect or something else? my $op = `install.sh -f my_conf -p my_ip -s my_server`; When the above is executed, a password line is printed: Enter pas...

issues with expect -send: spawn id exp4 not open

My expect code does this: It does a ssh connect to another machine, sends the password and then returns the hostname of that machine. I give a sample of my code below #!/usr/bin/expect -f set ipaddr [lrange $argv 0 0] set password [lrange $argv 1 1] set timeout -1 spawn ssh root@$ipaddr hostname match_max 100000 expect "*assword:*" send...

tcl/tk - expect - doesnot force input to spawned process

package require Expect #### Log File Name ##### set logFile "mtte_result.log" set NextLine "\n" set RTSPrompt "RTS_Mon-> " exp_spawn plink.exe -telnet -P 10009 10.245.97.42 set spid $spawn_id #exp_send $NextLine flush stdout ##### Log the session to the File ######### exp_log_file -noappend $logFile exp_sleep 5 exp_send $NextLi...

Tcl Serial Port fconfigure portability issue

Hi all, I've got a Tcl/Expect program that reads and writes data to the serial port. I did all of my development and testing on a Fedora 7 machine, but I'm now trying to run the same code in Ubuntu 8.10, and I'm getting the following error: spawn: returns {0} bad option "-mode": should be one of -blocking, -buffering, -buffersize, -enc...

Installing java on linux using ssh

Hi I want to install java on many computers using ssh so I want to write a bash script that will do (roughly): for c in computers do scp jre--.rpm $c ssh $c 'sudu -s; chmod a+x jre--.rpm ; ./jre--.rpm; echo "success!"' done The problem is that during the java installation I need to "read" the notice and type "yes" at the en...

Using conditional statements inside 'expect'

I need to automate logging into a TELNET session using expect, but I need to take care of multiple passwords for the same username. Here's the flow I need to create: Open TELNET session to an IP Send user-name Send password Wrong password? Send the same user-name again, then a different password Should have successfully logged-in at t...

spawn process in win XP

Hello All I am trying to create a automated ftp log in script in Expect/TCL. This is my script spawn ftp 100.100.100.1 expect ".*:" send "username" expect ".*:" send "password" expect ".*>" I get an error in Windows XP saying , it encountered an error and needs to close . But same thing work on a windows 2000 ....

How can I send arrow key presses to a process using Expect.pm

Hi all: Seems like this should be obvious, but how do I send arrow key presses to a process using Expect.pm? Does it depend on the terminal type I am using (vt100) or do I send keyboard scancodes? TIA. ...

Expect argument handling

I'd like to create an expect script that connects to the server via telnet and does some authorisation. I have a problem with using script parameters though. Based on man I expected this to work: #!/usr/bin/expect -f spawn telnet $argv1 5038 ... Unfortunately I get back can't read "argv1": no such variable. How can make this work? ...

Conditional statament inside expect command called from a bash script

I've been trying to automate some configuration backups on my cisco devices, i've already managed to do the script that accomplishes the task but I'm trying to improve it to handle errors too. I think that's necessary to catch the errors on two steps, first just after the 'send \"$pass\r\"' to get login errors (access denied messages) a...

How to embed gcc and gcov command in expect script

Hi, I wanted to embed gcc and gcov command as part of expect script.. I tried as.. #!/usr/bin/expect -f send ":gcc -fprofile-arcs -ftest-coverage c.c\r" send ":gcov c.c\r" But it doesnt run and execute the commands. Any insights to this? Thanks. ...

Expect/TCL telnet proc does not wait for the prompt

Hello , I have a Expect proc that sends command for telnet login and send commands. Inside the telnet proc I do a TFTP . The size of the file is 10MB. But the telent prompt does not wait until the prompt appears .It waits for the timeout period and comes off. is there any way we can wait for the prompt in Expect . Regards, Mithun ...

How can I debug a Perl CGI script?

I inherited a legacy Perl script from an old server which is being removed. The script needs to be implemented on a new server. I've got it on the new server. The script is pretty simple; it connects via expect & ssh to network devices and gathers data. For debugging purposes, I'm only working with the portion that gathers a list of ...

default timeout handler for expect script

I have a expect script that need to fail when certain any of the expect condition is not meet. For example: expect "Hello World" If the expect script does not find "Hello World" in certain amount of time, it should fail. According to expect manual, I can add a condition timeout in the expect, but I have many expect statements in the s...