1827987 Members
2438 Online
109973 Solutions
New Discussion

expect scripting error

 
Ratzie
Super Advisor

expect scripting error

I am trying to write an expect script that when it gets a certain prompt on
login it writes to a file to be mailed to me later....
I have the set variables at the beginning...

set LOG_FILE /home/c/logs/pass_set.log
set FILE [open /home/c/scripts/problem_list.txt "r"]
set ERROR_FILE /home/c/logs/connect_errors1.txt
set ERROR [ open $ERROR_FILE "w"]
set LOGIN_ERROR_FILE /home/c/logs/failed_logins1.txt
set PASS_ERROR_FILE /home/c/logs/passwd_change_error1.txt
set PASS_ERROR [ open $PASS_ERROR_FILE "w"]
set MAILTO someone@work.com
set SUBJECT_CONNECT "Failed Connections for acc account on [exec date]"
set SUBJECT_PASSWD "Failed Passwd Changes for acc account on [exec date]"

puts $ERROR "**** FAILED Connections ERROR LOG for [exec date] **** \n"
puts $PASS_ERROR "**** FAILED Passwd Changes ERROR LOG for [exec date] ****
\n"

####################################
I then start the script that source a file of IPs, and logs in, this is
where I need to get the error of
Invalid user name or password.

Here is chunks of the script...
####################################

proc acc_login {} {
send -- "acc1\r"
expect "Enter Password\r\n>$"
send -- "*************\r"
expect -exact "************\r"
expect "Invalid user name or password.\*$"
{
puts $PASS_ERROR "$LINE, Invalid user name or passwd, passwd was
not changed."; continue
}
}
#####################################################

This is the error when I run the script...

Enter User Name
>acc1
Enter Password
>************
Invalid user name or password.
Enter User Name
>invalid command name "
puts $PASS_ERROR "$LINE, Invalid user name or passwd, passwd was
not changed."; continue
"
while executing
"{
puts $PASS_ERROR "$LINE, Invalid user name or passwd, passwd was
not changed."; continue
}"
(procedure "acc_login" line 7)
invoked from within
"acc_login "


4 REPLIES 4
Stuart Browne
Honored Contributor

Re: expect scripting error

Could you attach these sections of code from the source instead of pasting them in?

The line-wrapping etc. makes it 'difficult' to be sure what the original says.
One long-haired git at your service...
Michael Schulte zur Sur
Honored Contributor

Re: expect scripting error

Hi,

I dont know this language but I wonder, if continue shouldnt be exp_continue?

greetings,

Michael
John Meissner
Esteemed Contributor

Re: expect scripting error

On think I usually do with expect is use "autoexpect" it writes the script for you basically.

man autoexpect for more details
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: expect scripting error

as for variables and such.... I've never used them in an expect script...
All paths lead to destiny