Coffeehouse Thread

4 posts

system() but for ASP

Back to Forum: Coffeehouse
  • User profile image
    RedShift

    Hello,

    php has a function called system where you can call system commands and executables, for example system('uptime')


    Is there something like that for ASP? I'd like to show the output of the 'uptime -a' on windows 2003 server in a webpage.
          

  • User profile image
    dalangalma

    System.Diagnostics has process-handling classes that let you deal with outside executables.

  • User profile image
    object88

    That seems like an odd place for it.

  • User profile image
    TommyW

    Something like this is how you would use it in C# (implies ASP.NET, not plain ASP). You'll need to add using lines for System.Diagnostics and System.IO, too:

    Process proc = new Process();
    proc.StartInfo.FileName = "uptime.exe";
    proc.StartInfo.Arguments = "-a";
    proc.StartInfo.UseShellExecute = false;
    proc.StartInfo.RedirectStandardOutput = true;

    proc.Start();

    StreamReader sw = proc.StandardOutput;
    string myString = sw.ReadToEnd();
    proc.Close();

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.