Re: [vox-tech] [OT] Pumping a password using Expect

2006-01-05 Thread Ken Bloom
On Thu, Jan 05, 2006 at 06:33:40PM -0700, timriley wrote:
> How do you have a crontab executed process using Expect
> pump a password to another computer?

Is this an SSH password you're giving it? If so, try using an SSH
keypair for authentication. A passwordless key is no less secure than
having the password in the expect file (it's probably more secure),
and you can even create single-purpose keys that can only be used to
run a single command (see http://www.arches.uga.edu/~pkeck/ssh/,
scroll down to "Single-purpose keys")

Also, you can try just a simpler regexp for the password. I know very
little about expect scripts -- only in the context of having seen it
in old PPP tutorials -- but they never used a full expression to
expect logins and password. For login they always used "ogin:" and for
password they always ued "word:". This would avoid capitalization
differences.

--Ken Bloom

-- 
I usually have a GPG digital signature included as an attachment.
See http://www.gnupg.org/ for info about these digital signatures.


signature.asc
Description: Digital signature
___
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech


Re: [vox-tech] [OT] Pumping a password using Expect

2006-01-05 Thread Jay Strauss
On Thursday 05 January 2006 7:33 pm, timriley wrote:
> then capture those SQL statements and send them to sqlplus.

Not to change the scope of your project, but why would you do it using 
sqlplus, as opposed to DBI?  You could avoid the whole login issue and 
probably get better performance.

Jay
___
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech


[vox-tech] [OT] Pumping a password using Expect

2006-01-05 Thread timriley

Hi All:

I'm trying to synchronize an Oracle database on one
computer from a Mysql database on the computer
“barracuda” by using Expect. Mysql has a nifty logging
feature which places all insert, update, delete, and other
altering commands into a file. My goal is to have
the "one" computer's crontab log into barracuda;
then barracuda will kick off a process which simply
"cat"s the Mysql log files. The "one" computer will
then capture those SQL statements and send them to sqlplus.

The challenge is for the "one" computer to send the
password to barracuda because barracuda (or any *nix computer)
accepts passwords only from a tty. OK, so here's
where Expect shines. Expect is a "see and say" programming
language which knows how to pump strings to a tty.
(It's called "see and say" because when it sees
"Password:", it can be programmed to say "thepassword".)

Well, Expect works find when the process is kicked off
from the command line; however, it fails to work when
executed from crontab.

Here is the Expect script:

#!/usr/bin/expect --
exp_internal 1
spawn ssh -l mysql_sync barracuda
expect [EMAIL PROTECTED] password: “
send “thepassword\r”
interact

Here is the output when the Expect script
successfully executes from the command line:

spawn ssh -l mysql_sync barracuda
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {26147}

expect: does "" (spawn_id exp4) match glob pattern "[EMAIL PROTECTED]'s 
password: "? no
[EMAIL PROTECTED]'s password:
expect: does "[EMAIL PROTECTED]'s password: " (spawn_id exp4) match glob 
pattern "[EMAIL PROTECTED]'s password: "? yes
expect: set expect_out(0,string) "[EMAIL PROTECTED]'s password: "
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "[EMAIL PROTECTED]'s password: "
send: sending "thepassword\r" to { exp4 }
tty_raw_noecho: was raw = 0  echo = 1
spawn id exp4 sent <\r\n>

Warning: No xauth data; using fake authentication data for X11 forwarding.
spawn id exp4 sent < \r\n\r\n

  
  *SYSTEM INFO   *
  

  Hostname  :   barracuda



spawn id exp4 sent 
Connection to barracuda closed.
interact: received eof from spawn_id exp4
tty_set: raw = 0, echo = 1
tty_set: raw = 3, echo = 0

Here is the output when the Expect script
fails to execute from crontab:

spawn ssh -l mysql_sync barracuda
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {26242}

expect: does "" (spawn_id exp3) match glob pattern "[EMAIL PROTECTED]'s 
password: "? no
[EMAIL PROTECTED]'s password:
expect: does "[EMAIL PROTECTED]'s password: " (spawn_id exp3) match glob 
pattern "[EMAIL PROTECTED]'s password: "? yes
expect: set expect_out(0,string) "[EMAIL PROTECTED]'s password: "
expect: set expect_out(spawn_id) "exp3"
expect: set expect_out(buffer) "[EMAIL PROTECTED]'s password: "
send: sending "thepassword\r" to { exp3 }
spawn id exp0 sent <\nexit 0\n\n>
interact: received eof from spawn_id exp0

Notice that whereas it seems to send the password,
there is no evidence that barracuda’s computer
was logged into.

How do you have a crontab executed process using Expect
pump a password to another computer?

--
Tim Riley



___
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech