Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I have used the "send" and "expect" cmd using fsecure but now when i am trying to do the same for putty its not allowing me.I just found like its able to identify the hostname but unable to send the password.how can i resolve this?also once it captures the password i want to send the sudo su - xyz and for which again i need to send the passwd and once it accepts then i want to do some grep frm the log file but i am just stucked in the initial stage itself.This is my following code.
#!/usr/local/bin/expect -fset force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}set timeout -1
set prompt "((%|#|:|>|\\$) |(%|#|:|>|\\$))$"
catch {set prompt $env(EXPECT_PROMPT)} exp_continue
#spawn $env(SHELL)
spawn "/bin/tcsh"
match_max 100000
expect -re $prompt
send -- "ssh -l [lindex $argv 1] [lindex $argv 0] \r"
expect {
# "(yes/no)? $" { send -- "yes\r"; exp_continue }
"password: $" { send -- "[lindex $argv 2]\r"}}
expect -re $prompt
send -- "sudo su - casep\r"
expect {
"password: $" { send -- "[lindex $argv 2]\r"}}
send -- "mon > /home/customer/newhire/`hostname`\r"
expect -re $promptsend -- "scp `hostname` customer@192.243.215.48:/home/customer/newhire/`hostname`\r"
expect {
"(yes/no)?*" { send -- "yes\r"; exp_continue }
"customer@192.243.215.48's password:*" { send -- "mishr999\r" }
}
expect -re $prompt
send -- "ssh -l customer 192.243.215.48 chmod 777 /home/customer/newhire/'hostname`\r"
expect {
"(yes/no)?*" { send -- "yes\r"; exp_continue }
"password: $" { send -- "mishr999\r" }Pls can someone advise.

![]() |
source routing
|
why soloris
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |