Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Calling exe with parameter doesn't work....

Reply
Thread Tools

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

 
 
christof
Guest
Posts: n/a
 
      03-18-2006
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.Fil eName).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
 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      03-18-2006
@"-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";




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"christof" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>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.Fil eName).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



 
Reply With Quote
 
 
 
 
christof
Guest
Posts: n/a
 
      03-18-2006
Juan T. Llibre wrote:
> @"-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
 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      03-18-2006
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 ?




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"christof" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
> Juan T. Llibre wrote:
>> @"-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



 
Reply With Quote
 
maczek
Guest
Posts: n/a
 
      03-18-2006
christof wrote:
> 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
 
Reply With Quote
 
christof
Guest
Posts: n/a
 
      03-18-2006
Juan T. Llibre wrote:

> 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 ?


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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing parameter to function not expecting parameter Mister B C Programming 8 08-26-2010 08:01 AM
decltype as a template parameter when containing reference to anothertemplate parameter. Isti C++ 2 04-19-2010 10:01 PM
without declare parameter [double square(parameter)] return 0 in main WanHongbin@gmail.com C Programming 5 10-01-2008 03:31 AM
Using declaration inside first template parameter as default valuefor second template parameter. Stuart Redmann C++ 5 12-14-2007 08:42 AM
Parameter List / Parameter Block / Anything patterns... mast2as@yahoo.com C++ 4 03-29-2007 09:37 PM



Advertisments