469,282 Members | 2,034 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Pass command-line argument to MySqlDump - How?

Hi All,

I'm running MySQL version: 5.0.15-nt on WinXP-Pro/SP2.

I created a one-line batch file DumpPAM.bat in a directory on the PATH:

mysqldump pmtallocmodel_development %1%.txt

I invoked it from a Command window with the command:

dumppam test

What I got was:

K:\>dumppam test
K:\>mysqldump pmtallocmodel_development 1>test.txt
K:\>

So I did get parameter substution, but I got that gratuitous "1"
added. What's the MySQL way of doing this, if it's possible?

Thanks in Advance,
Richard

Jul 16 '06 #1
3 6312
Hi All,

I'm running MySQL version: 5.0.15-nt on WinXP-Pro/SP2.

Here's another batch anomoly:

I created a two-line batch file Invoke2CreateTableStmts.bat in a "db"
directory under the current directory.

mysql pmtallocmodel_test < db\CreatePmtsTbl.sql
mysql pmtallocmodel_production < db\CreatePmtsTbl.sql
I invoked it from a Command window with the command:

K:\db\Invoke2CreateTableStmts.bat

What I got was:

K:\mysql pmtallocmodel_test 0<db\CreatePmtsTbl.sql
K:\mysql pmtallocmodel_production 0<db\CreatePmtsTbl.sql

This time there was no parameter substution, but I got that gratuitous
"0" added. Despite the strange zero, the commands seem to have worked
correctly. Any idea where the zeros are coming from?

Thanks in Advance,
Richard

Jul 17 '06 #2
Hi Richard,

I'm not running MySQL on Windows, but I believe you may be looking at
file descriptors. Basically (at least in *nix), the shell keeps track
of open files through the use of file descriptors (numbers). The first
3 are already defined:

STDIN = 0
STDOUT = 1
STDIN = 2

By default, you can use input and output redirection with
metacharacters < and >. The 0 and 1 are assumed. However, it looks
like they are being prepended to the metacharacters (ie. 0< file for
input redirection and 1file for output redirection). If you want to
redirect errors (again, in *nix), you would have to use 2file.

Hope this helps,
Brian

Richard wrote:
Hi All,

I'm running MySQL version: 5.0.15-nt on WinXP-Pro/SP2.

Here's another batch anomoly:

I created a two-line batch file Invoke2CreateTableStmts.bat in a "db"
directory under the current directory.

mysql pmtallocmodel_test < db\CreatePmtsTbl.sql
mysql pmtallocmodel_production < db\CreatePmtsTbl.sql
I invoked it from a Command window with the command:

K:\db\Invoke2CreateTableStmts.bat

What I got was:

K:\mysql pmtallocmodel_test 0<db\CreatePmtsTbl.sql
K:\mysql pmtallocmodel_production 0<db\CreatePmtsTbl.sql

This time there was no parameter substution, but I got that gratuitous
"0" added. Despite the strange zero, the commands seem to have worked
correctly. Any idea where the zeros are coming from?

Thanks in Advance,
Richard
Jul 17 '06 #3
Hi Brian,

Thanks for your thoughts. I don't think you're exactly right because
the spurious number seems to match the number of arguments in
batch-file invocation.

However, your plausible idea, coupled with the fact that the batch
files work as intended, makes me feel comfotable in continuing their
use.

So, again, thank you and
Best wishes,
Richard
Brian Mac wrote:
Hi Richard,

I'm not running MySQL on Windows, but I believe you may be looking at
file descriptors. Basically (at least in *nix), the shell keeps track
of open files through the use of file descriptors (numbers). The first
3 are already defined:

STDIN = 0
STDOUT = 1
STDIN = 2

By default, you can use input and output redirection with
metacharacters < and >. The 0 and 1 are assumed. However, it looks
like they are being prepended to the metacharacters (ie. 0< file for
input redirection and 1file for output redirection). If you want to
redirect errors (again, in *nix), you would have to use 2file.

Hope this helps,
Brian

Richard wrote:
Hi All,

I'm running MySQL version: 5.0.15-nt on WinXP-Pro/SP2.

Here's another batch anomoly:

I created a two-line batch file Invoke2CreateTableStmts.bat in a "db"
directory under the current directory.

mysql pmtallocmodel_test < db\CreatePmtsTbl.sql
mysql pmtallocmodel_production < db\CreatePmtsTbl.sql
I invoked it from a Command window with the command:

K:\db\Invoke2CreateTableStmts.bat

What I got was:

K:\mysql pmtallocmodel_test 0<db\CreatePmtsTbl.sql
K:\mysql pmtallocmodel_production 0<db\CreatePmtsTbl.sql

This time there was no parameter substution, but I got that gratuitous
"0" added. Despite the strange zero, the commands seem to have worked
correctly. Any idea where the zeros are coming from?

Thanks in Advance,
Richard
Jul 17 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Daniel Schwab | last post: by
2 posts views Thread by Robert | last post: by
7 posts views Thread by Zlatko Matić | last post: by
2 posts views Thread by Quarantine | last post: by
10 posts views Thread by John Bailo | last post: by
2 posts views Thread by glenn | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.