Re: "Driving" Linux Command Line from C# ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Michael B. Trausch wrote:
On Sat, 22 Nov 2008 02:27:35 +0100
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
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
.



Relevant Pages

  • Re: SFTP is not working
    ... When I try to use sftp or scp2, I get a message like this: ... sftp and scp2 both actually work by running ssh in a subprocess, ... The reason the shell startup files are relevant at all, ...
    (comp.security.ssh)
  • Re: Did you hack into my UNIX server Bible Bob?
    ... But that's not a shell question. ... >> OSX users, should I be using ssh instead of telnet for security? ... OSX as a built in firewall tab. ...
    (comp.unix.shell)
  • Re: Execute and lock a user into a program upon login
    ... logs in to the box via SSH, a command is run, and they immediately get ... dropped into the environment that the command produces. ... user is dropped into the application 'vtysh' ... shell drops (ie. user does not have to exit the csh shell to drop the ...
    (freebsd-questions)
  • Re: using ssh to run remote commands? [ssh -T, scp/ssh flags]
    ... I use SSH to forward connections between an intranet server at home and my ... To do this, the user on the remote machine need not have a shell, either ... start a shell on the remote host, ... you can have ssh run a command instead of an interactive shell by ...
    (FreeBSD-Security)
  • Re: Microsoft and Trust Take 2
    ... It seems safe to say that the whole Shell structure ... The design of Shell functionality is very ... Windows 7 MS hopes to eliminate the "old" API altogether: ...
    (microsoft.public.vb.general.discussion)