#!/bin/bash
expect << EOF
exp_internal 1
spawn ssh [email protected]
expect "ssword:"
send "********\r"
sleep 3
set list [open list1 r]
foreach line \$list
{
expect " $"
send "seeisso \$list | grep -E -i ' os |proddropdown|hostname'"
send "\r"
sleep 5
expect -re " $"
set fid [open out1.txt a]
puts \$fid \$expect_out(buffer)
}
close $fid
EOF
======
List 1 contains:
APSE0112
ETLLT0000
=============
result of the script:
expect: does " " (spawn_id exp6) match glob pattern " $"? yes
expect: set expect_out(0,string) " "
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) " "
send: sending "seeisso file7 | grep -E -i ' os |proddropdown|hostname'" to { exp6 }
send: sending "\r" to { exp6 }
expect: does "" (spawn_id exp6) match regular expression " $"? no
expect: does "\r\n" (spawn_id exp6) match regular expression " $"? no
seeisso file7 | grep -E -i ' os |proddropdown|hostname'
expect: does "\r\nseeisso file7 | grep -E -i ' os |proddropdown|hostname'\r\n" (spawn_id exp6) match regular expression " $"? no
===================
I don't know from where it is taking file7 value. and when i change:
send "seeisso \$list | grep -E -i ' os |proddropdown|hostname'"
to
send "seeisso **$list** | grep -E -i ' os |proddropdown|hostname'"
it takes an empty value:
expect: set expect_out(0,string) " "
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) " "
send: sending "seeisso | grep -E -i ' os |proddropdown|hostname'" to { exp6 }
send: sending "\r" to { exp6 }
expect: does "" (spawn_id exp6) match regular expression " $"? no
expect: does "\r\n" (spawn_id exp6) match regular expression " $"? no
seeisso | grep -E -i ' os |proddropdown|hostname'
===========
Please help
$list, (i.e.\$list)? Also, I don't see your use of thelinevariable.#!/usr/bin/expect -f.