Solved

expect script no longer works

Posted on 2002-07-17
2
216 Views
Last Modified: 2010-08-05
Hi,
 I have an "expect" script that runs fine on redhat 7.2,
but intermittenly works on redhat 7.3 (2.4.18-5). The expect script runs the passwd command to set a password to some variable. I can get the script if i add extra "returns" after sending the password. This is another querky issue that came about with this kernel, and I am wondering if it related.
Here is a snip of the script:
---------------snip---------------------
spawn /usr/bin/passwd $USER
expect {
       default { send_user "EXIT ERROR" ; exit 1 }
       "assword:"
       }
send "$PASS\r"
expect {
       default { send_user "EXIT ERROR" ; exit 1 }
       "assword:"
       }
send "$PASS\r"
expect {
       default { send_user "Completed.\n" ; exit 1 }
       }
send_user "\n Done.\n"
exit 0
--------------------------------------------
In order to make it work on 2.4.18-5, I have to
add extra "returns" to send $PASS, ie:
send "$PASS\r\r\r\r"
That works 100%, but is goofy , something is wacked!
0
Comment
Question by:medent
2 Comments
 
LVL 1

Accepted Solution

by:
m4rc earned 200 total points
ID: 7203702
expect can be goofy.  many problems ive run into are based on timing, and can be solved by slowing down the script to human speed, or adding sleep statements.
0
 

Author Comment

by:medent
ID: 7204059
a little sleep does wonders  
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question