expect

Sed does not work in expect

I made this bash one-liner which I use to list Weblogic instances running along with their full paths.This works well when I run it from the shell. /usr/ucb/ps auwwx | grep weblogic | tr ' ' '\n' | grep security.policy | grep domain | awk -F'=' '{print $2}' | sed 's/weblogic.policy//' | sed 's/security\///' | sort I tried to incorpora...

Find does not work in Expect Send command

I run this bash command to display contents of somefile.cf in a Weblogic domain directory. find $(/usr/ucb/ps auwwx | grep weblogic | tr ' ' '\n' | grep security.policy | grep domain | awk -F'=' '{print $2}' | sed -e 's/weblogic.policy//' -e 's/security\///' -e 's/dep\///' | awk -F'/' '{print "/"$2"/"$3"/"$4"/somefile.cf"}' | sort | un...

Python: win32console import problem

I want to run wexpect (the windows port of pexpect) on my Windows 7 64-bit machine. I am getting the following error: C:\Program Files (x86)\wexpect\build\lib>wexpect.py Traceback (most recent call last): File "C:\Program Files (x86)\wexpect\build\lib\wexpect.py", line 97, in raise ImportError(str(e) + "This package was intended f...

Using 'expect' in a secure fashion to automate logins/remote work

I have a server with which I cannot use pre-shared keys and ssh - all authentication is via interactive prompts. That server also has cron and at disabled for non-root users. I would like to be able to cron a job on my local machine that will run a script against the remote server to do periodic maintenance/reporting. I've dallied wit...

Alternative module of Net::SSH::Expect or how to connect remote server and get the output of command

I want to use Net::SSH::Expect in my unix box but unfortunately, it is not available and I am not able to convince the admin to install any perl module. Do you know how could I connect to a remote server using expect. I know that I can archive that by using python but python is also not avai in my unix box. Second attempt: though I use ...

How to install wexpect?

Hello, I'm running 32-bit Windows XP and trying to have Matlab communicate with Cgate, a command line program. I'd like to make this happen using wexpect, which is a port of Python's module pexpect to Windows. I'm having trouble installing or importing wexpect though. I've put wexpect in the folder Lib, along with all other modules. ...

How can I debug expect_before behaviour

I am relatively new to TCL / expect and mostly modifying existing code. expect_before doesn't seem to do what I expect (which is fine) but I can't work out how to debug it. I have used -d option and am now using exp_internal -f "argh.log" 1 to create a log file, but it isn't helping me. expect_before -info seems useful, but I am no...

SSH login with expect(1). How to exit expect and remain in SSH?

So I wanted to automate my SSH logins. The host I'm with doesn't allow key authentication on this server, so I had to be more inventive. I don't know much about shell scripting, but some research showed me the command 'expect' and some scripts using it for exactly this purpose. I set up a script and ran it, it worked perfectly to login....

Command not write in buffer with Expect

Hello, I try to backup a Linkproof device with expect script and i have some trouble. It's my first script in expect and i have reach my limits ;) #!/usr/bin/expect spawn ssh @IPADDRESS expect "username:" # Send the username, and then wait for a password prompt. send "@username\r" expect "password:" # Send the password, and then wait f...

how to hide ssh expect user/password

My Expect script shows password/user in clear text and I want to hide it. #!/usr/local/bin/expect ########################################################################################### ############ # Input: It will handle two arguments -> a device and a show command. ##############################################################...

Is there any real documentation or code examples on how to use the expect4j library?

The documentation on the google code project page is pretty thin. I'm wondering if there is any in depth documentation on using expect4j; code examples would be helpful as well. ...

How to get Command history by cursor key in Linux tclsh : TCL

I am new to TCL and I wanted to know, if I can get the command history by using cursor key (like up arrow key) in TCL shell (tclsh). I am running tclsh on fedora with linux version 2.6.21. ...

How can I automatically control a terminal?

I'm using 20 identical simulators (text base GUI like vi, refreshed quickly), and I need to control them in very similar way. e.g. input some command string to start/stop/config the simulator. The display is important, and I need them to flow on the terminal. Currently I can automatically start each one in a separate terminal. But afte...

In Tcl, seg faults from multiple threads requiring Expect

Now here's something interesting. When I have more than one thread in Tcl invoking package require Expect, I get a seg fault. e.g. package require Threads package require Expect set t [thread::create] thread::send {package require Expect} puts "blarg! Damned thing crashes before I get here" This is not a good time. Any thoughts?...

Perl expect - how to control timeout on target machine

Hello, I am a newbie to perl. I am using perl expect module to spawn to a remote system. Execute a set of commands there one after another using the send module(like $exp->send("my command as string goes here\n"). The problem is the commands that I execute take some time for processing . And before all the command finish the remote mach...

exit expect {} without timeout

I am struggling with the classic problem of typing password automatically in ssh, and like everybody else I am stumbling in the dark regarding expect. Finally I cobbled together a script that kinda work: #!/usr/bin/expect -f # command line args set user_at_host [lrange $argv 0 0] set password [lrange $argv 1 1] set timeout 1 # ssh c...

How to get expect -c to work in single line rather than script

Hi I was wondering if anyone had any examples of how to use expect with -c. Running: my_machine~/opt/ams/data/ep/success$ expect -c "spawn /usr/bin/scp xmlEventLog_2010-03-22T14-28-36_PFS_1_2.xml [email protected]:/opt/ams/epf_3_4/xmlEventLog_2010-03-22T14-28-36_PFS_1277900174_2.xml; expect { '*password:*' { send 'ad'\r\n }}" Doe...

How do I use Expect to connect with SSH?

In my program I use Expect to run ssh. My program is $argument="[email protected]"; $exp->spawn("ssh $argument") or die "Cannot spawn ssh to ip $ssh_ip_address\n"; But even if it is not able to spawn ssh it is not printing Cannot spawn ssh to ip $ssh_ip_address. Can you please help me understand why it does give the error message? ...

Using Expect to administer machines via SSH, but does not complete all tasks.

*Please do not pile on and tell me to just use SSH keys. If it bugs you that this is the way I am doing it, pretend that I am trying to telnet in instead. :-) * I am using an expect script to run some routine commands on a set of servers under my control via ssh. The script should run set of commands (eg svn update ~/folderx\r") on e...

Evaluating the Expect in perl

Hi I am using Expect in perl to connect to remote machine and execute certain functions. sample code is like $outfile="ls -lrt"; $outfile1="output"; $exp->expect(30,-re,".*bash-.*" => sub{$exp->send("$outfile2 >$outfile \r")}); $exp->expect(60,-re,".*bash-.*" => sub{$exp->send("$shayam > $Ram \r")}); Even if the first expression fai...