expect

Do an action for every match in expect

Hello, I am a total expect noob. I am writing a expect script for a test case where I want to count the number of occurrences of the string "Ok" and do an action for every occurrence from the following output: Reloading configuration on all nodes Reloading configuration on node 1 (node1-c5) OK Reloading configuration on node 2 (node2-c...

No result on standard output when running expect

Whenever I try to run the script it doesn't show me any result on standard output. #!/usr/bin/expect -- send [exec tail -f /var/opt/jboss/log/jbossall.log | grep -i "pattern"] Please advise the reason. ...

Expect Tcl script - Error passing quoted argument using spawn

I just wrote a very simple Expect script for wrapping around rsync, but it seems to be giving me trouble. Basically, I am automating the SSH login prompt called from rsync. I also have to pass arguments through rsync to SSH so it doesn't do the host key checking. I am well aware of SSH authentication keys and ssh-keygen, but I have go...

Can I use a heredoc to enter a password in bash?

I know about RSA authentication, but for my purposes I want to use a heredoc to specify the password. I want something like the following, but I can't get it to work. Is this even possible? #!/bin/bash echo -n "Enter Password: " read -s password ssh myhost << EOL $password echo "I'm logged onto myhost" EOL echo done This is what I g...

expect: exit on no action from programs' side

Hi, everyone I have a following script for executing commands on a remote device over ssh: #!/usr/bin/expect -f set cmd $argv set timeout -1 spawn ssh -p22 [email protected] match_max 100000 expect "*?assword:*" send "PASS\r" expect "<*" send $cmd\r expect "* :" send "Y\r" expect feof At the last line, my script is expecting "end of...

How to disable output buffering in Process.StandardOutput

This question has been asked more than once before, but I have not found a satisfactory answer in any of those discussions. I am launching a command-line process that produces a real-time measurement to STDOUT, producing a new result approximately every second. Using System.Diagnostics.Process.StandardOutput results in completely unacc...

expect: sequence of expects

Hello, everyone I'm trying to automate the interaction with a remote device over telnet using expect. At some point device generates output like this: ; ... COMPLETED ... ; What I need is to make my script exit after the "COMPLETED" keyword and second ";" are found. However all my attemts fail. Script either exits after the first com...

Can I call an Expect script from Perl by passing an array as a parameter?

Is it possible to call an Expect script from Perl by passing an array as a parameter? If so, how to retrieve that array in Expect like we retrieve non-array data as: set value [lindex $argv 0] ...

calling an expect script from perl script

hi.. here is my perl script(a.pl) #!/usr/bin/perl $logfile = "./a.log"; open(LOGFILE_Handle, ">$logfile") or die "Error : Can not open $logfile !!! \n\n "; print LOGFILE_Handle "a.pl: 1 "; system "./a.exp "; here is my expect script(a.exp) #!/opt/sfw/bin/expect -f log_user 1; set logfile "./a.log"; set LOGFILE_Handle [open "$log...

How do I send a password to a command I start with Perl's Expect.pm?

I have the following script, #!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; use Expect; my $logs = "logs"; open(LOG,'>>',"$logs") or die "can't logs $!\n"; my $domain = 'domain.com'; my @host = qw/host/; foreach my $host (@host) { my $cmd = "passwd user1"; my $sshost = join('.', $host, $domain); my $ssh = Net...

What's the best way to set an Eclipse breakpoint on a EasyMock expect call?

I have code like ClockService mockClockService = createMock( ClockService.class ); Long timeFirstNodeCreated = new Date().getTime(); expect( mockClockService.getNow() ).andReturn( timeFirstNodeCreated ) ; Long timeFirstNodeDeleted = new Date().getTime(); expect( mockClockService.getNow() ).andReturn( timeFirstNodeDeleted ) ; ...