Shell commands in ASP.NET?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Shell commands in ASP.NET?

    Hi,

    I want to execute a shell command and retrieve the output of it, is there a
    method to do it? All i have found is how to start a process (cmd /C), but i
    cannot retrieve the result of the command execution.

    For example, it would be ideal if there would be a method like:

    string result = ExecuteShellCommand("dir *.txt");

    thnx in advance...



    Allan Rojas Guest

  2. Similar Questions and Discussions

    1. Unable to execute shell commands
      Windows 2003 ISS 6.0 That's your problem ;) try using: Linux Debain Apache 1.3 Then it will execute the shell commands. windows does not...
    2. shell repeat commands
      in ksh, i can do the below 1) history 2) r history-number but for csh, i cant do the same. are there any similar alternatives?
    3. Windows Shell Commands
      Hi, how can i use windows shell commands with ruby ? I would like to call existing command line programs with parameters given by ruby. I am a...
    4. How do I escape shell commands?
      Is it possible to do something to a string so that it gets escaped for a shell command (i.e. if I'm executing a command and I have the file name...
    5. [PHP] executing shell commands.
      I am executing the following within PHP - $system = `/bin/ls /dcsa-ws1/share/webadm1/public_html/system-reports/security/rhosts/eqty | /bin/egrep...
  3. #2

    Default Re: Shell commands in ASP.NET?

    You want to look at the System.Diagnostics.Process namespace.


    Cheers!
    Dave
    [url]www.aspNetEmail.com[/url]



    "Allan Rojas" <ndrtkr@thecqgl.com> wrote in message
    news:enmRuDYQDHA.4024@tk2msftngp13.phx.gbl...
    > Hi,
    >
    > I want to execute a shell command and retrieve the output of it, is there
    a
    > method to do it? All i have found is how to start a process (cmd /C), but
    i
    > cannot retrieve the result of the command execution.
    >
    > For example, it would be ideal if there would be a method like:
    >
    > string result = ExecuteShellCommand("dir *.txt");
    >
    > thnx in advance...
    >
    >
    >

    dave wanta Guest

  4. #3

    Default Re: Shell commands in ASP.NET?

    I already did; but when executing the following code, i get a
    System.InvalidOperationException: StandardOut has not been redirected.


    System.Diagnostics.Process myP = System.Diagnostics.Process.Start("cmd",
    @"/C dir C:\");
    Response.Output.Write(myP.StandardOutput.ReadToEnd ());

    Thnx in advance...


    "dave wanta" <nospam@nospam.com> wrote in message
    news:O3FSbIYQDHA.560@TK2MSFTNGP10.phx.gbl...
    > You want to look at the System.Diagnostics.Process namespace.
    >
    >
    > Cheers!
    > Dave
    > [url]www.aspNetEmail.com[/url]
    >
    >
    >
    > "Allan Rojas" <ndrtkr@thecqgl.com> wrote in message
    > news:enmRuDYQDHA.4024@tk2msftngp13.phx.gbl...
    > > Hi,
    > >
    > > I want to execute a shell command and retrieve the output of it, is
    there
    > a
    > > method to do it? All i have found is how to start a process (cmd /C),
    but
    > i
    > > cannot retrieve the result of the command execution.
    > >
    > > For example, it would be ideal if there would be a method like:
    > >
    > > string result = ExecuteShellCommand("dir *.txt");
    > >
    > > thnx in advance...
    > >
    > >
    > >
    >
    >

    Allan Rojas Guest

  5. #4

    Default Re: Shell commands in ASP.NET?

    you probably need to set

    myP.StartInfo.RedirectStandardOutput = true;

    btw, if you only want to list out files, i would recommend the System.IO
    namespace.

    hth,
    Dave
    [url]www.aspNetEmail.com[/url]

    "Allan Rojas" <ndrtkr@thecqgl.com> wrote in message
    news:eN4FPSYQDHA.1040@TK2MSFTNGP12.phx.gbl...
    > I already did; but when executing the following code, i get a
    > System.InvalidOperationException: StandardOut has not been redirected.
    >
    >
    > System.Diagnostics.Process myP = System.Diagnostics.Process.Start("cmd",
    > @"/C dir C:\");
    > Response.Output.Write(myP.StandardOutput.ReadToEnd ());
    >
    > Thnx in advance...
    >
    >
    > "dave wanta" <nospam@nospam.com> wrote in message
    > news:O3FSbIYQDHA.560@TK2MSFTNGP10.phx.gbl...
    > > You want to look at the System.Diagnostics.Process namespace.
    > >
    > >
    > > Cheers!
    > > Dave
    > > [url]www.aspNetEmail.com[/url]
    > >
    > >
    > >
    > > "Allan Rojas" <ndrtkr@thecqgl.com> wrote in message
    > > news:enmRuDYQDHA.4024@tk2msftngp13.phx.gbl...
    > > > Hi,
    > > >
    > > > I want to execute a shell command and retrieve the output of it, is
    > there
    > > a
    > > > method to do it? All i have found is how to start a process (cmd /C),
    > but
    > > i
    > > > cannot retrieve the result of the command execution.
    > > >
    > > > For example, it would be ideal if there would be a method like:
    > > >
    > > > string result = ExecuteShellCommand("dir *.txt");
    > > >
    > > > thnx in advance...
    > > >
    > > >
    > > >
    > >
    > >
    >
    >

    dave wanta Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139