Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Shell functionlity

$
0
0

I've read through this thread several times, I started with SharpSSH, and had it working, but every-time I issued a new command to set the environment or do something else dependent I failed me, then I cam across your project, and figured since it was derived from that project, it would be further along, and actually have support. And thank you Oleg for moving the ball forward, I'm amazed what a nightmare this endeavor has become.

A Bit of background, there is a Xwindows user interface, that has 0 support to move over to Windows, but for some of my projects I need that flexibility, and the XWindows is actually an interface to a command-line tool. So I figured mimic the xwindows functionality in C# by telnetting to a Linux box, and bring the functionality it to windows.

I'm trying to grab data from the prompt, and I'm having a heck of a time, my problem seems twofold.

1) I'm trying to grab the Directories under a specific folder to populate a "Project" Dropdown, so that the correct environment can be set.

so I run, cd /company/projects/

then I want to wait for the prompt to appear, which I can do with 

 

stream = ssh.CreateShellStream("xterm", 80, 24, 800, 600, 1024);
Regex userPromptMatch = new Regex("\\$ $");

string test = stream.Expect(userPromptMatch);

 

which right now is relegated to jut look for a $ at the end.

and then get the data from the stream between the last read "reader.ReadToEnd();"

the issue is that as far as I can tell the stream.Expect doesn't return anything, and here's my second issue:

2) If I use the "reader.ReadToEnd();" i get 

cd /comapny/projects/Last login: Thu Jan 10 12:12:35 2013 from 10.55.2.36 ]2;server:~ /usr/company/adm/login: No such file or directory.[4m101[24m user@server:[1m~[0m $ Divider
cd /company/projects/ ]2;server:/company/projects [4m102[24m user@server:[1m/dd/shows[0m $  [4m102[24m user@server:[1m/dd/shows[0m $ 

so I added Encoding.UTF8 to it, just to make sure, and I get no difference, do I have to figure out what each of the ASCII codes is, and replace them to get a "Mortal" readable string ?

var reader = new StreamReader(stream, Encoding.UTF8);


Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>