Pass command-line argument to MySqlDump - How?
Pass command-line argument to MySqlDump - How?
am 16.07.2006 20:27:21 von Richard
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
Re: Pass command-line argument to MySqlDump - How?
am 17.07.2006 04:25:59 von Richard
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
K:\> mysql pmtallocmodel_production 0
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
Re: Pass command-line argument to MySqlDump - How?
am 17.07.2006 15:50:40 von Brian Mac
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 1> file for output redirection). If you want to
redirect errors (again, in *nix), you would have to use 2> file.
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
> K:\> mysql pmtallocmodel_production 0
>
> 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
Re: Pass command-line argument to MySqlDump - How?
am 17.07.2006 18:45:18 von Richard
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 1> file for output redirection). If you want to
> redirect errors (again, in *nix), you would have to use 2> file.
>
> 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
> > K:\> mysql pmtallocmodel_production 0
> >
> > 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