Hi All,
I have an expect script that I would like a perl script to call in order to login to a node and run in a single command.
The command being running is a log of events so has lots of data that will be output. I would like to output that data to a file.
Would anyone be kind enought to help me out please.
The expect script (below) is very basic as its used for several other scripts I have.
#!/usr/bin/expect
set timeout 20
set ip [lindex $argv 0]
set password [lindex $argv 1]
set cmd [lindex $argv 2]
spawn ssh -qo StrictHostKeyChecking=no sublookup@$ip
expect "password: "
send "$password\r"
expect -re "test14> "
send "$cmd\r"
expect -re "test24> "
send "exit\r"
I just need to understand how to print all the output text to a file as previously I have been selecting single bits of data.
the command used is 'show event history verbose' as yo can see below.
for my $target (keys %targets) {
print "A $target\n" if (DEBUG);
for (`../test/Scripts/lookup/ssh_run_cmd.exp $target $password "show event history verbose"`) {