problem with expect eof


 
Thread Tools Search this Thread
Operating Systems AIX problem with expect eof
# 1  
Old 08-31-2007
problem with expect eof

hi guys

i have such simple script, which i'm executing on AIX 5.3

Code:
#!/usr/local/bin/expect

spawn passwd exptest
set password 123
expect "*password:*"
send "$password\r"
expect "*password again:*"
send "$password\r"
expect eof

the output is following:
Code:
spawn passwd exptest
sh: /usr/local/bin/stty:  not found.
Changing password for "exptest"
exptest's New password:
Enter the new password again:

and that's it. script hangs at this place and i have no control with shell...

what could be the problem?
# 2  
Old 09-03-2007
Basically, your script seems correct, but I have no expect installed on AIX currently, so I can test it. Um, which version of expect is used ? What is the location of stty ? I have it under /usr/bin/stty, do a "which stty" and you can try to edit the $PATH and test again ?

I would wrote your script like :

Code:
#!/usr/local/bin/expect

spawn passwd exptest
set password some-pass
expect "*password:*"
sleep 1
send "$password\r"
expect "*password again:*"
sleep 1
send "$password\r"
expect eof

# 3  
Old 09-03-2007
Quote:
Originally Posted by sysgate
Basically, your script seems correct, but I have no expect installed on AIX currently, so I can test it. Um, which version of expect is used ? What is the location of stty ? I have it under /usr/bin/stty, do a "which stty" and you can try to edit the $PATH and test again ?
i have 5.43 version of expect downloaded from here AIX PDSLIB Package: expect

i also have stty located under /usr/bin, and $PATH is OK. i created symbolic link /usr/local/bin/stty to /usr/bin/stty, so i dont have warning about stty, but result of the script is the same.


Quote:
I would wrote your script like :

Code:
#!/usr/local/bin/expect

spawn passwd exptest
set password some-pass
expect "*password:*"
sleep 1
send "$password\r"
expect "*password again:*"
sleep 1
send "$password\r"
expect eof

this variant doesn't work either... script hangs
# 4  
Old 09-04-2007
By default the timeout is small number, and if the machine is hanging or responding slowly, you will loose the terminal created from "spawn". Try to do "set timeout -1" in the beginnig of the script and see if it helps. Use "-d" flag for debug and see what's going on.
# 5  
Old 09-06-2007
ok, now the script is followng

Code:
#!/usr/local/bin/expect -d

set timeout -1
set password 123
spawn passwd exptest
expect "*password:*"
sleep 1
send "$password\r"
expect "*password again:*"
sleep 1
send "$password\r"
expect eof

and again i cant control the shell

here is debug output, looks fine as for me :-)

Code:
# ./expp
expect version 5.43.0
argv[0] = /usr/local/bin/expect  argv[1] = -d  argv[2] = ./expp
set argc 0
set argv0 "./expp"
set argv ""
executing commands from command file ./expp
spawn passwd exptest
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {17710}

expect: does "" (spawn_id exp4) match glob pattern "*password:*"? no
Changing password for "exptest"
exptest's New password:
expect: does "Changing password for "exptest"\r\nexptest's New password: " (spawn_id exp4) match glob pattern "*password:*"? yes
expect: set expect_out(0,string) "Changing password for "exptest"\r\nexptest's New password: "
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "Changing password for "exptest"\r\nexptest's New password: "
send: sending "123\r" to { exp4 }

expect: does "" (spawn_id exp4) match glob pattern "*password again:*"? no

Enter the new pa
expect: does "\r\nEnter the new pa" (spawn_id exp4) match glob pattern "*password again:*"? no
ssword again:
expect: does "\r\nEnter the new password again:" (spawn_id exp4) match glob pattern "*password again:*"? yes
expect: set expect_out(0,string) "\r\nEnter the new password again:"
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "\r\nEnter the new password again:"
send: sending "123\r" to { exp4 }

expect: read eof
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "\r\n"

maybe something wrong with my AIX...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash expect problem

Hey there :) I have a Bash Script and I'm trying to update Roundcube, but theres a user interactive line like: bin/installto.sh /var/www/mail/rc Upgrading from 1.1.3. Do you want to continue? (y/N) I'm trying to avoid this user interaction like this: cd roundcubemail-1.2.1 >/dev/null... (5 Replies)
Discussion started by: Aeris
5 Replies

2. Shell Programming and Scripting

Problem with expect script

expect { -re "(.*)NEXT PAGE(.*)" { send "\r\n" } exp_continue (0 Replies)
Discussion started by: sagar_1986
0 Replies

3. Shell Programming and Scripting

problem with expect

i have written simple expect script but it doesnt work the way that i want can someone suggest wat is the issue? #!/usr/bin/expect spawn ssh abc@abc expect "password:" send "xyz\r" expect "$" send "mkdir hello\r" #sleep 10 #exit 0 output --------------- it does not create directory... (4 Replies)
Discussion started by: bkumar82
4 Replies

4. UNIX for Dummies Questions & Answers

EOF problem with Cron Job?

Hey guys... first post here... I have set up the following cron to create daily backups for me and rotate them weekly: date=`date +%d`; tar -zcvf /home/mysite/backups/backup_dev_$date.tgz /home/mysite/public_html/dev/app --exclude=/home/mysite/public_html/dev/app/tmp However, I keep... (4 Replies)
Discussion started by: Crazy Serb
4 Replies

5. Shell Programming and Scripting

EOF problem

hi i am trying to connect to database by two method one is sqlplus fss_blf/fss_blf@schema1 >select * from schema1_ta_example exit above method succesfffuly connect it to dabase but the problem comes when i try to enter this code into mine shell script by using EOF character it is... (4 Replies)
Discussion started by: aishsimplesweet
4 Replies

6. UNIX for Dummies Questions & Answers

Problem in Expect

Hi Im writing an expect program for automating ftp. Having trouble with mget: expect "ftp>" {send "mget *.txt\r"} expect "mget*?" {send "n\r" ; expect_continue} expect "ftp>" {send "bye\r"} But expect even on ftp prompt "n" gets sent Please help... (1 Reply)
Discussion started by: crackle1985
1 Replies

7. Shell Programming and Scripting

expect problem

hi all, guys i have a problem in this code... any help ? #!/usr/bin/expect if { $argc != 3 } { puts "Usage:" puts "$argv0 username oldpwd newpwd" exit } #set machine set username set oldpwd set newpwd set completed_list " " (2 Replies)
Discussion started by: b1sh0p
2 Replies

8. Shell Programming and Scripting

confused with << EOF EOF

Hi friends , I am confused with << EOF EOF Most of the cases I found sqlplus $db_conn_str << EOF some sql staments EOF another exapmle is #!/bin/sh echo -n 'what is the value? ' read value sed 's/XXX/'$value'/' <<EOF The value is XXX EOF (1 Reply)
Discussion started by: imipsita.rath
1 Replies

9. AIX

Problem with expect.

Hi, I am facing a strange problem while executing a script from a solaris server. This script calls another one to execute "expect" commands on some other 40 servers (all AIX 5200). I am passing username and password to the "expect" script as arguments. My problem is that it is showing the... (4 Replies)
Discussion started by: gsabarinath
4 Replies

10. Shell Programming and Scripting

EOF creating problem

In shell file, i am writing following statement: cat > File1.sh <<EOF set feedback off set serveroutput on cat > File2.sh <<EOF contents of second file EOF Contents of First file EOF Actually, i want these bolded statements in File1.sh as it. But after first EOF, contents are... (1 Reply)
Discussion started by: mmunir
1 Replies
Login or Register to Ask a Question