jeremychan
jeremychan

Reputation: 4479

Console application not doing anything

basically I would like to write an application to perform this in command prompt:

sslist -H -R -h s234.ds.net /mobile > listofsnapshot.txt

then this is my code when i create a c# console application:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Search
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = "sslist.exe";
            p.StartInfo.Arguments = "-H -R -h s234.ds.net /mobile";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.Start();

            string procOutput = p.StandardOutput.ReadToEnd();
            string procError = p.StandardError.ReadToEnd();

            TextWriter outputlog = new StreamWriter("C:\\Work\\listofsnapshot.txt");
            outputlog.Write(procOutput);
            outputlog.Close();

        }
    }
}

why when i execute my console script, it just hangs there and not do anything?

Upvotes: 0

Views: 87

Answers (1)

SLaks
SLaks

Reputation: 888185

sslist.exe is probably waiting for input.

You can send it some input by setting p.StartInfo.RedirectStandardInput to true, then writing to p.StandardInput.

Upvotes: 1

Related Questions