#!/usr/bin/expect
#Purpose : Retrieve command output of a remote machine using expect script
#Author : Ranjith Kumar R
#Date : 20th May 2013
set timeout 60
set log [open "log.txt" "w"]
spawn telnet IP address of a server
expect "login:"
send "username\r"
expect "Password:"
send "password\r"
expect "#"
send "command name"
send "\r"
set outcome $expect_out(buffer)
puts $log $outcome
send "exit\r"
expect eof
No comments:
Post a Comment