Computing.Net > Forums > Solaris > Unable to use send/expect cmd in PU

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unable to use send/expect cmd in PU

Reply to Message Icon

Name: Mishra
Date: July 3, 2007 at 11:38:26 Pacific
OS: SunOS
CPU/Ram: SunOS 5.8 Generic_117350
Product: sun4u sparc SUNW,Netra-T1
Comment:

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 -f

set 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 $prompt

send -- "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.




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


source routing why soloris



Post Locked

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


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: Unable to use send/expect cmd in PU

Unable to install Oracle 8i client www.computing.net/answers/solaris/unable-to-install-oracle-8i-client-/3269.html

Unable To Repair File System www.computing.net/answers/solaris/unable-to-repair-file-system/4693.html

Unable to save IP add. on hmeo www.computing.net/answers/solaris/unable-to-save-ip-add-on-hmeo/2327.html