 |
|
 |
I was make some changes in TerminalControl.cs (and some others files where I got error) to enable Telnet and Serial port connection... Telnet works fine but on serial connection I got error "The following error occurred when connecting to COM2. WaitCommEvent failed 6".
Here is my code:
public TerminalControl(string UserName, string Password, string Hostname, int Port, int BaudRate, ConnectionMethod Method)
{
this._connectionMethod = Method;
this._hostname = Hostname;
this._port = Port; this._baudrate = BaudRate; this._password = Password;
this._username = UserName;
this.InitializeTerminalPane();
}
public void Connect()
{
Poderosa.ConnectionParam.LogType logType = Poderosa.ConnectionParam.LogType.Default;
string file = null;
if (this.TerminalPane.Connection != null)
{
logType = this.TerminalPane.Connection.LogType;
file = this.TerminalPane.Connection.LogPath;
this.TerminalPane.Connection.Close();
this.TerminalPane.Detach();
}
try
{
if ((Poderosa.ConnectionParam.ConnectionMethod)this.Method == Poderosa.ConnectionParam.ConnectionMethod.Telnet)
{
TelnetTerminalParam tel = new TelnetTerminalParam(this.Host);
tel.Port = Port;
tel.TerminalType = TerminalType.VT100;
tel.RenderProfile = new RenderProfile();
tel.Encoding = EncodingType.ISO8859_1;
CommunicationUtil.SilentClient s = new CommunicationUtil.SilentClient();
Size sz = this.Size;
SocketWithTimeout swt;
swt = new TelnetConnector((Poderosa.ConnectionParam.TelnetTerminalParam)tel, sz);
swt.AsyncConnect(s, tel.Host, tel.Port);
ConnectionTag ct = s.Wait(swt);
this.TerminalPane.FakeVisible = true;
this.TerminalPane.Attach(ct);
ct.Receiver.Listen();
if (file != null)
this.SetLog((LogType)logType, file, true);
this.TerminalPane.ConnectionTag.RenderProfile = new RenderProfile();
this.SetPaneColors(Color.White, Color.Black);
}
else if ((Poderosa.ConnectionParam.ConnectionMethod)this.Method == Poderosa.ConnectionParam.ConnectionMethod.SSH2)
{
SSHTerminalParam sshp = new SSHTerminalParam((Poderosa.ConnectionParam.ConnectionMethod)this.Method, this.Host, this.UserName, this.Password);
sshp.AuthType = this.AuthType;
sshp.IdentityFile = this.IdentifyFile;
sshp.Encoding = EncodingType.ISO8859_1;
sshp.Port = Port;
sshp.RenderProfile = new RenderProfile();
sshp.TerminalType = TerminalType.XTerm;
CommunicationUtil.SilentClient s = new CommunicationUtil.SilentClient();
Size sz = this.Size;
SocketWithTimeout swt;
swt = new SSHConnector((Poderosa.ConnectionParam.SSHTerminalParam)sshp, sz, sshp.Passphrase, (HostKeyCheckCallback)null);
swt.AsyncConnect(s, sshp.Host, sshp.Port);
ConnectionTag ct = s.Wait(swt);
this.TerminalPane.FakeVisible = true;
this.TerminalPane.Attach(ct);
ct.Receiver.Listen();
if (file != null)
this.SetLog((LogType)logType, file, true);
this.TerminalPane.ConnectionTag.RenderProfile = new RenderProfile();
this.SetPaneColors(Color.White,Color.Black);
}
else if ((Poderosa.ConnectionParam.ConnectionMethod)this.Method == Poderosa.ConnectionParam.ConnectionMethod.Serial)
{
SerialTerminalParam stp = new SerialTerminalParam();
stp.BaudRate = BaudRate;
stp.FlowControl = FlowControl.None;
stp.Parity = Poderosa.ConnectionParam.Parity.NOPARITY;
stp.Port = Port;
stp.StopBits = Poderosa.ConnectionParam.StopBits.ONESTOPBIT;
stp.TerminalType = TerminalType.XTerm;
IntPtr pt = new IntPtr();
SerialTerminalConnection stcon = new SerialTerminalConnection(stp, pt, this.TerminalPane.Width, this.TerminalPane.Height);
ConnectionTag ct = new ConnectionTag(stcon);
this.TerminalPane.FakeVisible = true;
this.TerminalPane.Attach(ct);
ct.Receiver.Listen();
if (file != null)
this.SetLog((LogType)logType, file, true);
this.TerminalPane.ConnectionTag.RenderProfile = new RenderProfile();
this.SetPaneColors(Color.White, Color.Black);
}
else
{
throw new Exception("You must select a ConnectionMethod!");
}
}
catch
{
return;
}
}
And I was make Telnet (and serial but not tested) AutoLogin:
private List<string> getScreenContents()
{
List<string> returnList = new List<string>();
{
try
{
returnList.Clear();
int linecount = this.terminalControl.TerminalPane.ConnectionTag.Document.LastLineNumber + 1;
for (int x = 0; x < linecount; x++)
{
string outputLine = new string(this.terminalControl.TerminalPane.ConnectionTag.Document.FindLine(x).Text);
returnList.Add(outputLine);
}
}
catch
{
}
}
return returnList;
}
private bool TelnetAutoLogin(string UserWaitString, string UserSendString, string PassWaitString, string PassSendString)
{
if (LoggedIn == false && sendeduser == true && sendedpass == true)
{
foreach (string line in getScreenContents())
{
if (line.Contains("Login failed"))
{
LoggedIn = false;
return LoggedIn;
}
else
{
LoggedIn = true;
return LoggedIn;
}
}
}
if (sendeduser == true && sendedpass == false && finedpassprompt == false)
{
foreach (string line in getScreenContents())
{
if (line.Contains(">"))
{
LoggedIn = true;
return LoggedIn;
}
else if (line.Contains(PassWaitString))
{
finedpassprompt = true;
}
}
}
if (finedpassprompt == true && sendedpass == false)
{
this.terminalControl.SendText(PassSendString + "\n");
sendedpass = true;
}
if (sendeduser == false && fineduserprompt == false)
{
foreach (string line in getScreenContents())
{
if (line.Contains(">"))
{
LoggedIn = true;
return LoggedIn;
}
else if (line.Contains(UserWaitString))
{
fineduserprompt = true;
}
}
}
if (fineduserprompt == true && sendeduser == false)
{
this.terminalControl.SendText(UserSendString + "\n");
sendeduser = true;
}
return LoggedIn;
}
|
|
|
|
 |
|
 |
Hello
Even if you download the ZIP file above on Codeproject that states to be from 2009, the Poderosa code is not from 2009, it seems to be from around 2006.
This code is outdated.
The Poderosa project is still alive.
Today I downloaded a beta version from sept. 2011 which has nearly nothing in common with the code from 2006 anymore.
There are much more files and much more folders in the actual Poderosa project.
The latest version 4.3.5b available today consists of 520 source files in 40 folders.
Interesting features hav been added like SFT. New encryption algorithms have been added and new encodings and a lot more functionality (also COM port connections).
Now the project can be downloaded as binares with 12 already compiled DLLs: Granados.dll, Poderosa.XZModem.dll, Poderosa.TerminalSession.dll, Poderosa.Protocols.dll, etc...
There is also a fully functional EXE project that has a nice GUI with several menus and toolbars.
There is also an english documentation available as CHM file on Sourceforge. (Poderosa-4.3.5b-apidoc-en.zip) But this contains only the interface description of the classes without much usefull information.
Look here: Sourceforge Poderosa Project (latest Beta versions)
Nevertheless Poderosa is a huge project.
It is really huge and the code is so cryptic that even an experienced programmer may not understand it and has to trace through with the debugger.
Many functions are never called directly. Insted they are called from the Plug-in engine which manages a list of interfaces. You have to invest a lot of time before you can start making any changes to the code because if you don't understood it well you will break it.
There is nearly no helpfull documentation.
The comments in code are mostly in japanese.
So it is worth studying also your article here.
Elmü
modified 11 Feb '12.
|
|
|
|
 |
|
 |
i have connected to my local host system on port 23 for telnet.
then when i execute any dos command on this say 'dir[ENTER]' it gives me proper output.
but when i execute the same command again then it gives 'More ?' as response on screen and then not allow to fire any other command.
Does any one has face this issues ? any help on this ?
|
|
|
|
 |
|
 |
Hi,
do i have any chance to note a disconnect? Because of a logout or some error or so...
Thanks a lot!
|
|
|
|
 |
|
 |
not sure i understand what you mean
if you like you can put an event in the terminal control that you can subscribe and catch disconnect
|
|
|
|
 |
|
 |
Serveral people have asked this...
have a look at the TerminalDataReciever class. There's a method called DataArrived() are you use to gain access to the incoming bytes
|
|
|
|
 |
|
 |
First i would like to give some serious props to Sardaan Frostreaver - OUTSTANDING JOB - you saved me hundreds of dollars from ActivExpert/Jscape/ and so on. Excellent works out of the box.
I do a have a couple questions that i can't seem to find from pondarosa or any other area.
1. I would like to know how to capture the data from the terminal window.---> OR better yet - run a set of commands from a button click. For instance we have a storage array that i would like to allow our DBAs to see data on their volumes. And maybe in the future add some advanced features. Ideally i would like them to click a button and it pulls up all volumes that include SQL. I can figure that portion out just need to know how to issue commands via buttons. OR - i need to be able to record all data from the command line.
2. If i can record to file all data in the terminal window i can sort through and add some pretty GUI on the front end and hide your terminal window have a background processing type command window.
So i would like to be able to press SQL01 button and then from there it prints to a file that i can parse through using normal VB commands.
Thanks.
j
|
|
|
|
 |
|
 |
Actually, I have the same exact questions. I want to send command, extract the command output from the command sent, send a list of commands and process differently based on the output. It would be appreciated if anyone answer to these questions.
|
|
|
|
 |
|
 |
I haven't been here in ages
Very good questions and they are methods I have added to my Control but haven't posted yet. (yeah it's me, i just changed my display name)
You can use TerminalPane.Connection.WriteChars(char[]) to send text
There's also a method in TerminalPane.ResetLog(ConnectionParam, string file, bool append) that you can use to set up a log. I haven't played 'follow the rabbit down the hole' to discover a way to hook into Poderosa's output.
I should be able to post an update in a few weeks with some new things. Hopefully I can get that in as well. TerminalControl needs some cleaning.
|
|
|
|
 |
|
 |
Hi I have been trying very hard to find out how to read the outpur of any command that is executed.
For E.g- i type "ls -ltR" and i want to read the output of this command in some string. How can i do that?
If someone has done this then please help me....
|
|
|
|
 |
|
 |
Hi at all,
iḿ just going boring,
i want to to try to establish an telnet connection to an sco unix without success.
ssh works really fine but every time if i set the connection method to telnet nothing happens ???
anyone an idea???
|
|
|
|
 |
|
 |
are trying to connect via serial com?
|
|
|
|
 |
|
 |
no iḿ trying to connect over TCP/IP
|
|
|
|
 |
|
 |
Hi!, can anyone tell me how to use this to connect to a serial com?
|
|
|
|
 |
|
 |
thanks for dropping by. I haven't looked for Serial Port stuff in poderosa.
|
|
|
|
 |
|
 |
Hi guys i'm a open source software developer newbie and i hope im not feeding on anyone's resources. Im just in need for some help regarding the displaying and "removal" of escape sequences generated in my terminal program which i've scripted using vb.net
I've coded a ui for reading comports and connecting to other computer devices and i was able to boot the bios in my terminal but they are displaying weird stuff like
+[25;01H +[14;01H+[24;01H
[03:01H=================== etc etc
i suppose these codes are standard formatting sequence like the vt100 dec which i researched on google after spending 3 days i come to know about this. At first i thought they were garbage texts. So i'm wondering, how am i able to make use of the terminal control library dll file which i thought it might contain some of the formatting sequence which would help eliminate those characters.
I have spent days researching on this and i haven't come out a solution for it. :(
|
|
|
|
 |
|
 |
Anyone know how to utilize only the terminal emulator portion of this control? I just want to leverage the terminal emulator capabilities and not be tied to an ssh service. If so, how would I then access/send data to the emulator gui portion?
|
|
|
|
 |
|
 |
make a class that inherits TerminalPane and override all the comm stuff
at least in theory it should work
|
|
|
|
 |
|
 |
I downloaded your c# example (newer version). and it comes with ssh example only. it works perfectly.
could you pls add telnet and serial port example in c#?
|
|
|
|
 |
|
 |
REPLACE this...(on TerminalControl.cs)
//try
//{
// //------------------------------------------------------------------------
// SSHTerminalParam sshp = new SSHTerminalParam((Poderosa.ConnectionParam.ConnectionMethod)this.Method, this.Host, this.UserName, this.Password);
// sshp.AuthType = this.AuthType;
// sshp.IdentityFile = this.IdentifyFile;
// sshp.Encoding = EncodingType.ISO8859_1;
// sshp.Port = 22;
// sshp.RenderProfile = new RenderProfile();
// sshp.TerminalType = TerminalType.XTerm;
// CommunicationUtil.SilentClient s = new CommunicationUtil.SilentClient();
// Size sz = this.Size;
// SocketWithTimeout swt;
// swt = new SSHConnector((Poderosa.ConnectionParam.SSHTerminalParam)sshp, sz, sshp.Passphrase, (HostKeyCheckCallback)null);
// swt.AsyncConnect(s, sshp.Host, sshp.Port);
// ConnectionTag ct = s.Wait(swt);
// this.TerminalPane.FakeVisible = true;
// this.TerminalPane.Attach(ct);
// ct.Receiver.Listen();
// //-------------------------------------------------------------
// if (file != null)
// this.SetLog((LogType)logType, file, true);
// this.TerminalPane.ConnectionTag.RenderProfile = new RenderProfile();
// this.SetPaneColors(Color.LightBlue, Color.Black);
//}
//catch
//{
// //MessageBox.Show(e.Message, "Connection Error");
// return;
//}
with this...
TelnetTerminalParam tel = new TelnetTerminalParam(this.Host);
tel._port = 23;
tel.TerminalType = TerminalType.VT100;
tel.RenderProfile = new RenderProfile();
tel.Encoding = EncodingType.ISO8859_1;
CommunicationUtil.SilentClient s = new CommunicationUtil.SilentClient();
Size sz = this.Size;
SocketWithTimeout swt;
swt = new TelnetConnector((Poderosa.ConnectionParam.TelnetTerminalParam)tel, sz);
swt.AsyncConnect(s, tel.Host, tel.Port);
ConnectionTag ct = s.Wait(swt);
this.TerminalPane.FakeVisible = true;
this.TerminalPane.Attach(ct);
ct.Receiver.Listen();
if (file != null)
this.SetLog((LogType)logType, file, true);
this.TerminalPane.ConnectionTag.RenderProfile = new RenderProfile();
this.SetPaneColors(Color.LightBlue, Color.Black);
then go to Form1.cs
replace this... //"this.terminalControl1.Method = WalburySoftware.ConnectionMethod.SSH2;"
with this "this.terminalControl1.Method = WalburySoftware.ConnectionMethod.Telnet;"
|
|
|
|
 |
|
 |
Hi,
Great control. Thanks for posting it.
Is there a way to simply connect to a unix server, send a command and capture the response without using the GUI.
Apparently other people have asked that question, but I don't see any answers.
I would appreciate any help. Thanks
Denson.
|
|
|
|
 |
|
 |
HI,
I am also having the same kind of requirement. If there is any solution kindly, let me know. What I noticed is that the entire codes works in an asynchronus manner Which makes it difficult to separate out commands and responses.
|
|
|
|
 |
|
 |
Hello
I what I do is:
Everything what appears in the terminal, remains recorded in a string that is updated by a timer, them remove what I do not want. For example I throw the command "ls" and with String.IndexOf("ls") from the command ls included backward I erase it of the string.
It would also be using #,$.. and with a list of specific commands, to extract positions of the string.
To synchronize and to realize searches in this string, I do a kind of timeout.
I take the date, add micro-seconds that I want and tell the program that do events.
System. WinForms. Application. DoEvents ();
Until it spends the micro-seconds that I want to synchronize.
This system me has been useful to realize a system of macros, seemed to the scripts of the machine and that is throwing commands depending on the answers that of the machine.
I wait to have helped
pd.Sardaan thanks for the code if you need help with anything you say memodified on Monday, March 1, 2010 12:23 AM
|
|
|
|
 |
|
 |
Hello,
I spend about 5 hour to reverse how to get output value from previous terminal line, hope save your time
example how to get output message in char array from previous line
insert this command for example to button and you get value in test:
char[] test = terminalControl1.TerminalPane.ConnectionTag.Document.LastLine.PrevLine.Text;
simple
Best Regards
Kamil
|
|
|
|
 |
|
 |
very nice, thank you for this!
|
|
|
|
 |