472,127 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

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 6379
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 Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.