in reply to Re^2: Issue with Expect
in thread Issue with Expect
I would guess that the password input is accepting the "\r" as an input terminator (because login/password type input is wonky like that) but the proper input terminator for the type of session input and for general shell commands is "\n".#!/usr/bin/env perl use 5.014; use warnings; use Expect; my $exp = Expect->new; $exp->spawn('ssh tak'); $exp->expect(10, '~$ '); # prompt. using ssh keys so no password $exp->send("ls\n"); $exp->expect(10, '~$ '); $exp->send("exit\n"); $exp->soft_close(); __END__ Output: zengargoyle@tak:~$ ls ... ls output ... zengargoyle@tak:~$ exit logout Connection to tak closed.
Just a guess, unless your Solaris is wonky or running some special shell (not csh/sh/etc) you should be using "\n". I've done a bunch of Expect stuff with Solaris, routers, switches, ... over ssh and never have I used "\r". I always use "\n" and have never had the sort of problem you seem to be having.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Issue with Expect
by azstyx (Acolyte) on Mar 23, 2012 at 20:32 UTC |