Multiple PromptReceived don't seem to work - WeOnlyDo Discussion board

Multiple PromptReceived don't seem to work (General questions)

by hactic, Monday, October 09, 2006, 15:58 (6620 days ago)

Hello :-)

I'm using TelnetDLX ActiveX , and I'm wondering how I can delay the sending of the next command. I send the username, but I want it to wait with sending until the Password prompt has returned. I know that there is a way of setting the PromptReceived to a new value, but in the code that I used below , it doesn't work. Could you please tell me what I am doing wrong there.

instance of the code :

axwodTelnetDLX1.Prompt = ( login: );
axwodTelnetDLX1.PromptReceived += new EventHandler(Sendusername);
axwodTelnetDLX1.Connect(Host, null, null);

private void Sendusername(object sender, EventArgs e)
{
axwodTelnetDLX1.Send(Username +
);
axwodTelnetDLX1.Prompt = ( Password: );
axwodTelnetDLX1.Send(Password +
);
return;
}

The other problem that I have is that the ActiveX version doesn't support the Execute method as used in the COM version. Is there a way with Ax to trigger an event, after the previous event is finished. If not, then I have to apply threading to myapplication. I read something about it in the documentation, but I could figure out how it is used. Could you please give me an example ( C# ) on how to use all this.

Thanks in advance.

Re: Multiple PromptReceived don't seem to work

by wodDrazen, Monday, October 09, 2006, 16:30 (6620 days ago) @ hactic

Hi,


If you set Blocking Property to True, than wodTelnetDLX will execute line by line. Wait to execute first command and that go to second (if your code is working good).

Other option which is better is that you use Login and Password Property instead Send Method for authentication to server.

Here is example in C#. Example will show you how to connect to some server and execute some command (ls -al in this case) with wodTelnetDLX:

-----------------------------------------
tel1 = new WODTELNETDLXCOMLIB.wodTelnetDLXCom();

tel1.Hostname = your_server_name ;
tel1.Protocol = WODTELNETDLXCOMLIB.ProtocolsEnum.Telnet;
tel1.Login = your_login ;
tel1.Password = your_password ;
tel1.Blocking = true;
tel1.Connect( your_server_name ,23,WODTELNETDLXCOMLIB.ProtocolsEnum.Telnet);

tel1.WaitFor ( regex:[$ #>] $ ,30);
textBox1.Text = textBox1.Text + (tel1.Execute ( ls -al +
, regex:[$ #>] $ ,30));
-----------------------------------------

More help for Blocking Property you can find here:
http://www.weonlydo.com/TelnetDLX/Help/WODTELNETDLXLIB~wodTelnetDLX~Blocking.html

Hope I helped.


Regards,
Drazen

Re: Multiple PromptReceived don't seem to work

by hactic, Monday, October 09, 2006, 17:02 (6620 days ago) @ wodDrazen

Drazen,

Thank you so much for your quick reply. The problem is that I'm not using the COM library but the ActiveX library. The code sample that you have given me is for the COM library. I have used the COM library before, and it works pretty good with the code that you have supplied.However, I am very keen on getting the ActiveX component to work.

The other thing is that I have made a dropdown list of computers that users can pick from, and of course each computer has a different name and password. I also want to send commands after that, depending on what computer the user connects to. If I set the username and password in the ActiveX terminal , it connects perfectly. However, due to earlier mentioned reason, I need to send it manually. Again, I can do this using the COM lib. but I would like to use the ActiveX one.

Regards,

Re: Multiple PromptReceived don't seem to w

by wodDrazen, Monday, October 09, 2006, 17:30 (6620 days ago) @ hactic

Hi,


Well it worked for me, this is my code, please try it out:
-------------------------------------------
private void Form1_Load(object sender, EventArgs e)
{

axwodTelnetDLX1.Connected += new AxWODTELNETDLXLIB._IwodTelnetDLXEvents_ConnectedEventHandler(axwodTelnetDLX1_Connected);

axwodTelnetDLX1.Hostname = server_name ;
axwodTelnetDLX1.Protocol = WODTELNETDLXLIB.ProtocolsEnum.Telnet;
axwodTelnetDLX1.Login = login ;
axwodTelnetDLX1.Password = password ;
axwodTelnetDLX1.Connect( server_name , 23, WODTELNETDLXLIB.ProtocolsEnum.Telnet);


}

void axwodTelnetDLX1_Connected(object sender, AxWODTELNETDLXLIB._IwodTelnetDLXEvents_ConnectedEvent e)
{
textBox1.Text = connected ;
}
-------------------------------------------

My code connect to server and fired Connected Event.

You can get Events by entering for Connected Event in Form Load:

axwodTelnetDLX1.Connected += and double press Tab button on your keyboard and you will get:

-------------------------------------------
axwodTelnetDLX1.Connected += new AxWODTELNETDLXLIB._IwodTelnetDLXEvents_ConnectedEventHandler(axwodTelnetDLX1_Connected);

void axwodTelnetDLX1_Connected(object sender, AxWODTELNETDLXLIB._IwodTelnetDLXEvents_ConnectedEvent e)
{
//here you can add code for Connected Event
}
-------------------------------------------

for other Events procedure is same.

I can prepare you sample if you want. Please send e-mail to techsupport@weonlydo.com for sample.

Hope this helps.


Regards,
Drazen

Re: Multiple PromptReceived don't seem to work

by hactic, Monday, October 23, 2006, 10:49 (6606 days ago) @ wodDrazen

wodDrazen

Sorry I couldn't get back to you sooner, but your code works perfect. I wasn't aware that you can also use the COM commands but it works absolutely perfect now.

axwodTelnetDLX1.Hostname = this.txtConIPaddress.Text;
axwodTelnetDLX1.Protocol = WODTELNETDLXLIB.ProtocolsEnum.Telnet;
axwodTelnetDLX1.Login = this.txtConUser.Text;
axwodTelnetDLX1.Password = this.txtConPass.Text;
NameSite = this.cmbConSite.Text;
axwodTelnetDLX1.PrintText( Trying to connect to + NameSite + ...
);
axwodTelnetDLX1.Connect(this.txtConIPaddress.Text, 23, WODTELNETDLXLIB.ProtocolsEnum.Telnet);
axwodTelnetDLX1.Connected += new AxWODTELNETDLXLIB._IwodTelnetDLXEvents_ConnectedEventHandler(QueryRTRadar);

Once again, thank you for your assistance.