Hi :

I try your scripts except changing the spawn directory but still does not work. I 
wonder is it because my mysql is window version and I am running the Expect scripts in 
the Cygwin environment.Here is the output below. It looks like Expect is not getting 
the feedback from mysql output.It keep waiting for "mysql>" but did not find it.

spawn /cygdrive/c/mysql/bin/mysql test
select version();
select now();
quit;
version()
4.0.5-beta-max-nt
now()
2003-01-03 14:28:07
ERROR 1064 at line 3: You have an error in your SQL syntax.  Check the manual th
at corresponds to your MySQL server version for the right syntax to use near 'qu
it' at line 1

-----Original Message-----
From: Paul DuBois [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 03, 2003 2:11 PM
To: Paul Choy; [EMAIL PROTECTED]
Subject: RE: Can Expect scripts interact with mysql ?


At 11:37 -0800 1/3/03, Paul Choy wrote:
>"Paul Choy" writes:
>  >Hi :
>  >
>  >I am trying to run Expect scripts to interact with mysql. So far I 
>cannot get
>  > it to work here is the list of log I got.Does anyone know how to 
>interact Ex
>  >pect scripts with mysql. What am I missing ?
>
>I've done it, but I don't spawn directly.  I spawn a regular shell
>and then just send out the command to start it, eg
>
># start up command line interface to mysql
>send "/usr/local/mysql/bin/mysql -u root -p $dbname\r"
>
>and go on from there.  Works just fine.
>
>--Cindy

I just tried using expect on Jaguar, and didn't find it necessary to
spawn a shell.  Here's my script:

% cat junk
spawn /usr/local/mysql/bin/mysql test
send "select version();"
expect "mysql>"
send "select now();\r"
expect "mysql>"
send "quit;\r"
expect EOF


And here's the result of running it:

% expect junk
spawn /usr/local/mysql/bin/mysql test
select version();Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 52 to server version: 4.0.8-gamma-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select version();select now();
+-----------------+
| VERSION()       |
+-----------------+
| 4.0.8-gamma-log |
+-----------------+
1 row in set (0.01 sec)

+---------------------+
| now()               |
+---------------------+
| 2003-01-03 16:08:06 |
+---------------------+
1 row in set (0.01 sec)

mysql> quit;
Bye

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to