Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Message-ID: <4377.217.162.71.141.1091808058.squirrel@217.162.71.141>
In-Reply-To: <6.1.0.6.0.20040806105531.033469a0@pop.prospeed.net>
References: <1614.217.162.71.141.1091552632.squirrel@217.162.71.141> <6.1.0.6.0.20040803172459.0338a528@pop.prospeed.net> <3552.217.162.71.141.1091799815.squirrel@217.162.71.141> <6.1.0.6.0.20040806105531.033469a0@pop.prospeed.net>
Date: Fri, 6 Aug 2004 18:00:58 +0200 (CEST)
Subject: Re: Redirect stdout from SSH
From: "David E. Meier" <dev@eth0.ch>
To: "Cygwin List" <cygwin@cygwin.com>
User-Agent: SquirrelMail/1.4.3a
MIME-Version: 1.0
Content-Type: text/plain;charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Virus-Scanned: by amavisd-new at inetworx.ch
X-IsSubscribed: yes

OK, short overview: I am working on a program in C# that needs to run some
commands on a remote machine and therefore I use SSH. The output will then
be written into a textbox. In C# you can run a command like this:

Process MyProcess = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = @"c:\cygwin\bin\ls";
psi.Arguments = "-al";
psi.UseShellExecute = false;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
MyProcess.StartInfo = psi;
MyProcess.Start();
+ textbox handling stuff.

This command will run 'ls' without creating the Command Window and outputs
the the listing of the direcotry as expected in the textbox. Now, when I
want to invoke SSH in the same manner, setting these values:

psi.FileName = @"c:\cygwin\bin\ssh";
psi.Arguments = "-i /path/to/key user@host ls -al";

then I have to explicitly set

psi.RedirectStandardInput = true;

or else it won't work. Although I see the command executing by observing
some network action there is nothing returned to the textbox and CPU stays
at 100%. There is nothing that needs to be written to stdin such as a
passphrase or so. However, programs using SSH, such as rsync, don't need
to set RedirectStandardInput = true to write their output to the textbox.
I just wonder what's the difference.

Dave.

> At 09:43 AM 8/6/2004, you wrote:
>>I got it working when standard input is also set to be redirected. Does
>>anyone have an explanation of this?
>
>
> No, sorry.  At least not without some details of what you did.  Like I
> said,
> the simple example I put together worked fine for me so it seems clear
> that
> there's a detail which is missing that accounts for the behavior you're
> seeing.  Did you try that example?  If you need me to, I can send the
> code,
> though it just invokes 'ssh' as you describe via 'system()'.
>
> If you can point to how your example is different than mine or provide a
> simple example that shows the problem, that might help.
>
>
>>> At 01:03 PM 8/3/2004, you wrote:
>>>>Hello list,
>>>>
>>>>I am writing a program in C# that calls some cygwin programs and
>>>> redirects
>>>>the standard output and error to a textbox. This works excellent with
>>>>calls like "ls -al" or rsync.
>>>>
>>>>However, I cannot read the output generated by SSH. When I issue a
>>>> command
>>>>like "ssh user@host ls -al" I can observe some network action but the
>>>>application stalls, uses 100% CPU and never spits out something. The
>>>> same
>>>>command in the cygwin shell executes with the result expected. Since I
>>>> use
>>>>public key authentication SSH is not waiting for any login information.
>>>>
>>>>Is this a configuration issue of SSH? Thanks for any help. Dave.
>>>
>>>
>>> Not AFAICS.  A small C program that invokes Cygwin's 'ssh' via
>>> 'system()'
>>> with 'ls -al' works fine for me.  Does that work for you?
>
> --
> Larry Hall                              http://www.rfk.com
> RFK Partners, Inc.                      (508) 893-9779 - RFK Office
> 838 Washington Street                   (508) 893-9889 - FAX
> Holliston, MA 01746
>
>
>



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

