1

The original Unix implementation simply did something like this:

ssh [batchname] < [inputfilename] > [outputfilename]

I need to be able to do the same thing from a windows machine running an application written in C#. I've tried using SharpSsh, which includes input and output streams, but they don't seem to work.

How can I pipe the input and output files/streams using SharpSsh (or any other .Net library)?

4
  • "It doesn't work" is too broad. Did you try to debug the code? What problems did you have? Commented Jan 19, 2011 at 5:39
  • It depends on what I tried to do. In general, the behavior was like the streams never connected with the server. I don't know if the input stream ever got information to the server, but the output stream was always either closed and unreadable or a read would hang for far longer than it should have (should take a second or two, waited for minutes). Commented Jan 19, 2011 at 17:35
  • To be more explicit, if I use SshExec.RunCommand and simply add the input file contents to the command string (separating with a space or a newline), the RunCommand call doesn't return. If I use SshShell and write out the command and input file, the output stream is not available or remains empty. Commented Jan 19, 2011 at 20:11
  • Can you please post a code snippet how you figured it out? I am facing the same issue actually :( Need your help. Thanks in advance. Commented Jun 7, 2011 at 8:46

1 Answer 1

1

Figured it out. Either the application running or SSH itself expects a ctrl-d to signal the end of the input. At that point, the output stream can be read without hanging.

Sign up to request clarification or add additional context in comments.

1 Comment

FYI: You can accept your own answer to let others know that it exists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.