Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15939

How to execute shell command which uses a pipe

$
0
0
Hey

I'm trying to pipe output from mysqldump to mysql using a pipe. It works just fine in a dos prompt, but fails when I use it in ShellExecute.
The simplified command is:
Code:

    r = ShellExecute(0, "open", "mysqldump.exe", _
        "mysqldump --user=foo --password=foo --host=192.168.1.2 --compress --verbose some_db | mysql --user=bar --password=bar --host=localhost some_db", _
        mariadbPath & "\bin", 1)

The cmd window pops up for a split second then closes, too fast to see what it says - anyone know how to prevent it from closing?

If I run that in a loop, I can step through the loop (F8) and the cmd window re-opens so often that I can make out what it says - authentication failure. It's not treating the pipe character as a pipe, it's not treating the stuff after the pipe symbol as a separate "mysql" command, but as arguments to the first "mysqldump" command.

Same problem if instead I try "foo > somefile.txt", the chevron is not treated as redirection.

How do I feed data from one command to another via a pipe? Must work in WinXP and Win10.

Viewing all articles
Browse latest Browse all 15939

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>