#!/usr/local/bin/expect --
set usern "testuser"
set passw [exec aprogramtogetpassword $usern]
set timeout -1
eval spawn sqlplus $usern
log_user 0
expect "Enter password: "
# why do I need the following sleep?:
sleep 1
send "$passw\r"
log_user 1
expect {
"Enter user-name: " exit
"Connected"
}
interact
Oracle's sql is taking too long to do the "stty -echo" required to hide the
password. You're doing the right thing by adding a sleep of a second or two.
--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
Are you going to Scarborough Fair?
---------------------------------------------------------------------------
Gary L. Burnore | нлГКнГоГКнГГнлКнГоГКнГнГоГКнГннлГ
| нлГКнГоГКнГГнлКнГоГКнГнГоГКнГннлГ
Official .sig, Accept no substitutes. | нлГКнГоГКнГГнлКнГоГКнГнГоГКнГннлГ
| нл 0 1 7 2 3 / нГо 3 7 4 9 3 0 лГ
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
===========================================================================
> while, the password shows on the screen, and expect just sits there
> waiting for something, and doesn't make it to interact. If I put in a
> 'sleep 1', I don't have this problem, but am not sure why. Any
> pointers? I'd like to (1) avoid the delay if possible, and (2) insure
> that the password never shows even with the 'sleep', but without knowing
> what's happening, I'm not confident that 'sleep 1' will always work.
(You can get this text by using autoexpect to autogenerate an expect script)
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts. If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 (see below) makes Expect do this
# automatically - pausing briefly before sending each character. This
# pacifies every program I know of. The -c flag makes the script do
# this in the first place. The -C flag allows you to define a
# character to toggle this mode off and on.
More information may be available in the Exploring Expect book, or on
comp.lang.tcl.
Ashwin
--
Ashwin Baskaran
Cisco Systems
Did you try to call sqlplus like this:
sqlplus /NOLOG
You will get a SQL> prompt and can connect:
SQL> connect <user>/<passwd>@<ORACLE_SID>
- Oliver