Call External scripts from mysql

the MYSQL.exe offers:

system command, \! command

Executes the given command using your default command interpreter.

The system command works only in Unix.

You'll have to test it to see if it works inside a Stored Procedure on UNIX.

>

Thanks, Jay


 Peter Brawley:

 It's a MySQL client command, not a server command.



source http://rocky-says.blogspot.com/2009/03/mysql-client-tips-2-running-shell.html{

Mysql: Client Tips 2: Running Shell Commands from the Commandline



Ok, As you know I am trying to explore more of the mysql command line and exploring its features. I have already written about how to change default mysql prompt using the command "prompt" in one of my previous articles.

Continuing this series. I am focusing today on the "system" command or "/!".

Well, I always have some of the sql source files and I execute it from the mysql command line. But I just keep forgetting their names. And most of the times I either close the mysql session and do 'ls' at the command line or move the mysql session in background and do a 'ls'.

Mysql cli has this very useful command called "system" using which you can execute shell commands from mysql client itself.

just type
system ls -l
or
\! ls -l
Some of us, who are familiar with Vim, will like this "\!" version a lot, because we are already using ! to run system commands there.

You can run almost all system commands using either of system or '\!'

Some examples:
mysql:root@test [14:26:19 pm]$ \! pwd
/home/owner

mysql:root@test [14:29:33 pm]$ \! date
Thu Mar 26 14:29:46 SGT 2009

mysql:root@test [14:29:46 pm]$ \! bash
owner@rocky-desktop:~$ exit
mysql:root@test [14:30:12 pm]$
You see the last one is quiet interesting. You can actually open a shell using this command perform some tasks. Just exit from the shell and you are back in the mysql world.

Liked it ! Start playing with mysql client system command.
It's actually possible to execute shell commands on the server that mysqld is running though a client connection (rather than executing commands on the client machine locally) by using MySQL Proxy (scroll down to the "Shell commands from MySQL client" section ).
Author :http://semmyfun.blogspot.com/
Mysql Proxy:



To run a script from within mysql simply to the following
mysql> source d:/my documents/run.sql;
Where d:/my documents/run.sql is the path and name of the script you want to run.




The UDF Repository for mysql http://www.mysqludf.org/




Other links found about mysql proxy
http://fmpwizard.blogspot.com/2009/04/how-do-i-use-mysql-proxy-admin-plugin.html
https://answers.launchpad.net/mysql-proxy/
http://forge.mysql.com/wiki/MySQL_Proxy
http://forge.mysql.com/tools/tool.php?id=81
http://planet.mysql.com/
https://forums.oracle.com/forums/thread.jspa?threadID=539084
http://www.chriscalender.com/?p=6