B4J Question jShell: redirecting stdout to file by parameter?

KMatle

Expert
Licensed User
Longtime User
I've got this command with args in a windows batch file (*.bat) to dump a database:

B4X:
C:\xampp\mysql\bin\mysqldump -u root -ppw dbname > "C:\xampp\htdocs\xxx\Dumps\dbname.sql"

The output is redirected to a file by ">"

In B4J I don't get it:

B4X:
 sh.Initialize("sh", "C:/xampp/mysql/bin/mysqldump.exe", Array As String("-u root", "-p","pw", "dbname")

works (stout contains the dump).

Trying to redirect the output with ">" to a file doesn't

B4X:
 sh.Initialize("sh", "C:/xampp/mysql/bin/mysqldump.exe", Array As String("-u root", "-p","pw", "dbname",  ">", "C:\xampp\htdocs\xxx\Dumps\dbname.sql"))

I could write stout to a file but is it possible to do it by a parameter?
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

you could try

B4X:
sh.Initialize("sh", "C:/xampp/mysql/bin/mysqldump.exe", Array As String("-u root", "-p","pw", "dbname",  ">C:\xampp\htdocs\xxx\Dumps\dbname.sql"))
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
I tried "all" combinations. MySQL assumes everything behind dbname as a table or another db.

I found an explicit paramter "--result-file=". Now it works:

B4X:
sh.Initialize("sh", "C:/xampp/mysql/bin/mysqldump.exe", Array As String("-u", "root", "-ppw", "dbname","--result-file=C:\xampp\htdocs\xxx\Dumps\dbname.sql"))
 
Upvote 0
Top