Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6881919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:11:23+00:00 2026-05-27T05:11:23+00:00

I am working on an automation strategy for our QA group and need to

  • 0

I am working on an automation strategy for our QA group and need to be able to capture the output of scripts and EXE files. When I run this code as a console application, I am able to successfully capture the output of plink.exe:

class Program
{
    static void Main(string[] args)
    {
        Process process = new Process();
        process.StartInfo.FileName = @"C:\Tools\plink.exe";
        process.StartInfo.Arguments = @"10.10.9.27 -l root -pw PASSWORD -m C:\test.sh";
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.RedirectStandardOutput = true;
        process.Start();

        string output = process.StandardOutput.ReadToEnd();
        process.WaitForExit();

        output = output.Trim().ToLower(); // Output is successfully captured here

        if (output == "pass")
        {
            Console.WriteLine("Passed!");
        }
    }
}

This command takes about a minute to execute and I successfully capture the results to the output variable.

However, when I compile the same code as a DLL and run through NUnit, the code completes immediately and fails with the value of output == NULL:

[TestFixture]
public class InstallTest
{
    [Test]
    public void InstallAgentNix()
    {
        Process process = new Process();
        process.StartInfo.FileName = @"C:\Tools\plink.exe";
        process.StartInfo.Arguments = @"10.10.9.27 -l root -pw PASSWORD -m C:\test.sh";
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.RedirectStandardOutput = true;
        process.Start();

        string output = process.StandardOutput.ReadToEnd();

        process.WaitForExit();

        output = output.Trim().ToLower();

        Assert.AreEqual("pass", output, "Agent did not get installed");
    }
}

I have narrowed the problem down to the line string output = process.StandardOutput.ReadToEnd(). If I comment the line out, execution time is around a minute and the operation is successfully executed on the remote machine (test.sh gets executed on a remote Linux box).

I hope I’m missing something simple – I don’t want to have to find a different test harness.

It looks similar to the (unsolved) question here: Why does a process started in a DLL file work when tested using console application, but not when called by another DLL file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:11:24+00:00Added an answer on May 27, 2026 at 5:11 am

    OK, it took me all night but I figured it out. I have to RedirectStandardInput in addition to redirecting standard output for this to work.

    Here is the fixed code that works in a DLL file. As an FYI, this fix resolves the problem in a Windows Forms application as well:

    [TestFixture]
    public class InstallTest
    {
        [Test]
        public void InstallAgentNix()
        {
            Process process = new Process();
            process.StartInfo.FileName = @"C:\Tools\plink.exe";
            process.StartInfo.Arguments = @"10.10.9.27 -l root -pw PASSWORD -m C:\test.sh";
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardInput = true;
            process.Start();
    
            string output = process.StandardOutput.ReadToEnd();
    
            process.WaitForExit();
    
            output = output.Trim().ToLower();
    
            Assert.AreEqual("pass", output, "Agent did not get installed");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on writing some automation code and I'm running into a problem finding
Hi i am working on an internet explorer automation and this is new territory
I am working on an automation server using mingw. MIDL MyAutomationLib creates the files
I am working on a web automation tool. After the tool is run once
I'm working on UI automation. We are using the following tools. Bewildr Snoop Our
I'm working on a software for test automation. To get it working it need's
Been working on a personal add-in for VS 2008 and have been researching automation
We are working on automation various different web/client applications, using several different frameworks (WatiN,
I am working on Build Automation via Team Build (TFS 2008). We are using
I'm working for small company, which operates in the automation industry. The boss hired

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.