Calling exe with parameter doesn't work....

C

christof

I wish to use an exe file, it looks like this:


System.Diagnostics.Process mysqldump = new System.Diagnostics.Process();

mysqldump.StartInfo.FileName = @"C:\Program Files\MySQL\MySQL
Server 5.0\bin\mysqldump.exe";


Response.Write(File.Exists(mysqldump.StartInfo.FileName).ToString());
//just to check if I'm pointing right


mysqldump.StartInfo.Arguments = @"-u myuser --password=mypass
my5 > F:\\MySQL\\Backup\\my5a";

mysqldump.StartInfo.CreateNoWindow = false;
mysqldump.StartInfo.ErrorDialog = true;
mysqldump.StartInfo.RedirectStandardOutput = true;
mysqldump.StartInfo.UseShellExecute = false;


try
{
Response.Write(mysqldump.Start().ToString());
}
catch (Exception exc)
{
Response.Write(exc.Message);
}


I'm gettin True (file exists) and True (Process.Start()) and no
exception is caught, but there is no effect.

If i simply call in shell:
mysqldump -u myuser --password=mypass my5 > F:\\MySQL\\Backup\\my5a
it works fine, backup is created.

What am I doing wrong?

Thanks a lot
 
J

Juan T. Llibre

@"-u myuser --password=mypass > my5 > F:\\MySQL\\Backup\\my5a";

produces :

-u myuser --password=mypass my5 > F:\\MySQL\\Backup\\my5a

as the output, which will fail silently as a bad path.

If you use the @ to create a literal string, remove the double slashes.

Use :

..Arguments =@"-u myuser --password=mypass > my5 > F:\MySQL\Backup\my5a";

OR use :

..Arguments ="-u myuser --password=mypass > my5 > F:\\MySQL\\Backup\\my5a";
 
C

christof

Juan said:
@"-u myuser --password=mypass > my5 > F:\\MySQL\\Backup\\my5a";

produces :

-u myuser --password=mypass my5 > F:\\MySQL\\Backup\\my5a

as the output, which will fail silently as a bad path.

If you use the @ to create a literal string, remove the double slashes.

Use :

.Arguments =@"-u myuser --password=mypass > my5 > F:\MySQL\Backup\my5a";

OR use :

.Arguments ="-u myuser --password=mypass > my5 > F:\\MySQL\\Backup\\my5a";

I did it especially so I don't think it is a reason:

In windows in shell you have to launch mysqldump like

mysqldump -u user --password=pass db_name > C:\\Dir\\File

with double backslashes or simply:

mysqldump -u user --password=pass db_name > C:/Dir/File

both works fine from shell, so the problem is not here.

Thanks anyway
 
J

Juan T. Llibre

re:
I did it especially so I don't think it is a reason:

Regardless of whether you "did it especially", the way you're doing it is failing.

Did you test the alternate ways I suggested you do it ?
 
M

maczek

christof said:
I wish to use an exe file, it looks like this:
[...cut...]

I experienced the similar problem several times. It's called Mr.
Glowacky's problem and it's probably not yet solved. It's just like
"Hilbert's tenth problem" or even "Goldbach conjecture".

Hope my message will help you :)

Best regards!

maczek
 
C

christof

Juan said:
re:

Regardless of whether you "did it especially", the way you're doing it is failing.

Did you test the alternate ways I suggested you do it ?

Yes, but unfortunately it didn't help, i was suggested to add, this a
line of code:

Response.Write(mysqldump.StandardOutput.ReadToEnd());

in my try block and i see the response on the screen, which is generated
normally by mysqldump.exe when i run it from shell, but it's only the
beggining of what i'm getting in the right output backup file.

Looks like this:

-- MySQL dump 10.10 -- -- Host: localhost Database: my5 --
Server version 5.0.15-nt /*!40101 SET ...
[...]
*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

and cuts here. In the proper bakup file, it continues here:

[...]
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `account`
--

DROP TABLE IF EXISTS `account`;
[...]

and so on with sql statements.

Maybe some more suggestions
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top