Re: "Driving" Linux Command Line from C# ?
- From: Josh <jhofmo@xxxxxxxxxxx>
- Date: Sat, 29 Nov 2008 06:25:38 +0100
Michael B. Trausch wrote:
On Sat, 22 Nov 2008 02:27:35 +0100Mike,
Josh <jhofmo@xxxxxxxxxxx> wrote:
I've had surprisingly little success in finding answers to this by
the usual Google search. Putty is great for manual work, but no API
exposed. Plink is too asynchronous so scenarios like: pass command,
plug response to variable/array/object, then pass to if/else
structure then send next command just won't work. I'd think there
would be an SSH utility with an API but if it exists I haven't been
able to find it. Any suggestions?
There is an SSH library for .NET, SharpSSH. It is written in C#, and
is licensed under extremely friendly terms (BSD-like license). Also in
the top ten at Google for "C# SSH".
http://www.tamirgal.com/home/dev.aspx?Item=sharpSsh
Surely somebody must have automated Linux with C# by now...
Well, working with the command line is obviously going to be more
difficult than just using the SSH component, but the SSH component will
be a good start. Just be sure that you are sure about the shell on the
other end of the connection---most systems use GNU bash by default, but
some people (like me!) are known to change systems to not use that. If
you want to be sure about the shell, though, it'd not be a bad idea for
the first thing you explicitly start GNU bash or whatever other shell
you're programming for. If you have systems that are more than just
Linux systems, then you'll want to target the Bourne Shell (/bin/sh),
which every UNIX and UNIX-like system I know of has installed.
--- Mike
Sorry for the late response. I got sidetracked with some personal dramas. Anyway, trying to get back on track here. So yeah, I am still working on this project and had hoped that maybe there would be a SSH client with an API exposed to save some coding time. I'm currently looking into options like Ponderosa and Grenados but I'm not sure if they will be any easier to work with than just using SharpSSH and coding my own integration with Bash or Bourne shell from scratch. The latter sounds like a terrible amount of work and I am to be fair a pretty junior developer.
BTW have you or has anyone here worked with Ponderosa or Grenados and if so do you think it might fit the bill for what I'm doing?
Thanks again for the feedback.
JR
.
- References:
- "Driving" Linux Command Line from C# ?
- From: Josh
- "Driving" Linux Command Line from C# ?
- Prev by Date: Re: Is there a way to get sqlclr code to call MessageBox.Show() ?
- Next by Date: Re: Are people abusing "var"?
- Previous by thread: "Driving" Linux Command Line from C# ?
- Next by thread: About 'Copy always' flag for MDF files
- Index(es):
Relevant Pages
|