Using Expect output in a script.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Cheramie

    Using Expect output in a script.

    I'm unsure how to break down and use what is returned by expect in the
    rest of my script. I want to issue a command and split the results of
    that command into several different variables. I then want to use
    those variables in the rest of my script. Here is a snipet:

    $expcxn = Expect->spawn("telne t 10.10.10.10\r") or die "Cannot spawn
    telnet: $!\n\n";
    $expcxn->expect($timeou t, "assword:") or die "Did not get a password
    prompt: $!/n/n";
    print $expcxn "thepassword\r" ;
    $expcxn->expect($timeou t, "go>") or die "Did not get command prompt:
    $!/n/n";
    print $expcxn "show info $ARGV[0]\r";
    $expcxn->expect($timeou t, "go>") or die "Did not get command prompt:
    $!/n/n";
    exit(-1);

    The 'show info' command is what produces the info I want to split and
    use. What do I have to do to get whatever is returned and put it into
    variables I can use in other commands?
Working...