开发者

Redirect input from another command in windows batch files

In linux I 开发者_JAVA技巧can do something like this:

mysql -u user -p=pass somedb <(echo "create database foo;")

How can I do that with windows batch scripts?

Basically, I want to make a batch file that runs a sql script without having to keep the script in a separate file.

Thanks


One way is to echo the SQL commands into a file, run the mysql command with option to include the SQL file, and then remove the file (if you really don't want it.)


You can do

echo create database foo;|mysql ...

just fine, but for multiple lines you really want to make a temporary file you just pass to MySQL to read.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜