Reputation: 4102
I'm working on a project that require me to use window task scheduler to execute mysql query, this is the batch file content:
mysql -ufoo -pbar -D %1 < %2
when I tested the batch file via cmd:
task_sheduler.bat dbName pathToSqlFile
I get:
mysql -ufoo -pbar -D dbName 0<pathToSqlFile
I just want to say that its working, my question is what is about the extra space and the 0, where did they came from?
Upvotes: 3
Views: 232
Reputation: 67216
I assume your Batch file does NOT have an @echo off
command, so you refer to the echo of commands that appear in the screen when a Batch file is executed. The display of these commands frequently include additional characters that cmd.exe inserts to display exactly the executed commands.
In the case of redirections, <input
is a short form of Stdin redirection, and the number of Stdin is zero, so the real redirection is 0<input
. The same happens with >output
, that is echoed as 1>output
. cmd.exe also remove multiple spaces from the original code and insert needed ones in order to clearly show the executed commands.
If you want not to see these command expantions, just insert an @echo off
command at beginning of your Batch file.
Upvotes: 3
Reputation: 3068
cmd prefixes all redirection commands by the default handle if none is provided. The handles are defined here. 0<file
thus means that we want file to be redirected to standard input. The extra space is there to prevent a command like hi.exe<myfile
from being wrongly interpreted as hi.exe0 < myfile
Upvotes: 1