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

Discussion in 'ASP .Net' started by christof, Mar 18, 2006.

  1. christof

    christof Guest

    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
    christof, Mar 18, 2006
    #1
    1. Advertising

  2. @"-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" <> wrote in message news:...
    >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
    Juan T. Llibre, Mar 18, 2006
    #2
    1. Advertising

  3. christof

    christof Guest

    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
    christof, Mar 18, 2006
    #3
  4. 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" <> wrote in message news:%...
    > 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
    Juan T. Llibre, Mar 18, 2006
    #4
  5. christof

    maczek Guest

    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
    maczek, Mar 18, 2006
    #5
  6. christof

    christof Guest

    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
    christof, Mar 18, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kaspar Minosiants

    exe file made by JBuilder doesn't work

    Kaspar Minosiants, Sep 24, 2003, in forum: Java
    Replies:
    0
    Views:
    390
    Kaspar Minosiants
    Sep 24, 2003
  2. MZ
    Replies:
    7
    Views:
    814
    Ed Mullen
    Mar 17, 2008
  3. Paddy
    Replies:
    4
    Views:
    352
    Ian Kelly
    Mar 25, 2011
  4. Oren
    Replies:
    4
    Views:
    206
  5. PerlFAQ Server
    Replies:
    0
    Views:
    246
    PerlFAQ Server
    Apr 26, 2011
Loading...

Share This Page