Telnet and Visual Foxpro - WeOnlyDo Discussion board

Telnet and Visual Foxpro (wodSSHServer)

by jtrogdon, Wednesday, January 10, 2007, 15:16 (6310 days ago)

I'm evaluating the SSHServer ActiveX component in a project I'm working with Visual FoxPro. I want to be able to telnet to the server running under Visual Foxpro. At this time, I do not want any logins or authentication. I want the user to be able to telnet to the server's IP address and the server run the shell or another program I choose. This is all for a test and I know about the possible security problems.

I can telnet to the server and get the banner but after that the cursor is flashing and nothing else happens. I have set the Action to 1 in the LoginPassword method but I'm stuck at what I need to do next to get the telnet server to run the shell or another program. Any help in leading me in the right direction would greatly be appreciated.

Re: Telnet and Visual Foxpro

by woddrazen, Wednesday, January 10, 2007, 16:03 (6309 days ago) @ jtrogdon

Hi,


I have duplicated you problem.

I have contact our main programmer about your problem and we will answer you soon as we find some solution.


Regards,
Drazen

Re: Telnet and Visual Foxpro

by jtrogdon, Wednesday, January 10, 2007, 16:30 (6309 days ago) @ woddrazen

While we are waiting on that, I added this to the LoginPassword method:

IF Login = james .AND. password = james
Action = 1
ELSE
Action = 0
ENDIF

This would at least allow me to get a DOS prompt as a test even though I had to login as james .

My second question: How do I redirect Visual Foxpro text and prompts to the telnet client and receive data back? I want to start to write a simple menu using the @SAYs and GETs from Visual Foxpro that basically displays text and prompts. The menu would look something like this:

1. Border Scanning
2. Bottom Scanning

Type Choice:

The telnet client would choose an option and then program would continue that would allow the telnet client to add, delete and modify records using prompts that would collect that information. I need to do this inside Visual Foxpro so I can have access to all the classes I need in order to write the records. Is this possible? Thanks for the help.

Re: Telnet and Visual Foxpro

by wodDamir, Wednesday, January 10, 2007, 16:41 (6309 days ago) @ jtrogdon

Hi,

Please try using Send and Receive Methods.

You can find more information on Send Method on the following link:
http://www.weonlydo.com/SSHServer/Help/wodSSHDLIB~SSHUser~Send.html

And more info on Receive Method is availible here:
http://www.weonlydo.com/SSHServer/Help/wodSSHDLIB~SSHUser~Receive.html

Hope this helps.

Regards,
Damba

Re: Telnet and Visual Foxpro

by woddrazen, Thursday, January 11, 2007, 20:19 (6308 days ago) @ wodDamir

Hi,


Your problem should be fixed.

Please download latest version from our site and let us know how it goes.


Regards,
Drazen

Re: Telnet and Visual Foxpro

by jtrogdon, Thursday, January 11, 2007, 20:36 (6308 days ago) @ woddrazen

Hi,

Your problem should be fixed.

Please download latest version from our site and let us know how it goes.

Regards,
Drazen

Yes, that fixed the problem but now the banner doesn't finish displaying before my menu displays. Here's what is looks like from the telnet screen:

This is demo version of WeOnlyDo! SSHD ActiveX component, for evaluation purpose
s only. You are not allowed to use this product in production environment.
PFI Barcode Scanning

1. Border Scanning
2. Bottom Scanning
3. Panel Scanning
4. Label Scanning
5. Build-Up Scanning
6. Print Report

Type Choice: wodSSHServer DEMO version

I'm using the User.Send() to send the text to the telnet client but I also need to know how to display prompts that wait for the user to type some data. I've never done this before with telnet so I may not understand all the ends and outs. Any suggestions you can give would greatly help. Thanks.

Re: Telnet and Visual Foxpro

by woddrazen, Thursday, January 11, 2007, 21:25 (6308 days ago) @ jtrogdon

Hi,


Please try something like this in VisualFoxPro_
[code]
Private Sub SSHD1_LoginPassword(ByVal User As wodSSHDComLIB.ISSHUser, ByVal Login As String, ByVal Password As String, Action As wodSSHDComLIB.SSHActions)
Action = Allow
End Sub

Private Sub SSHD1_ServiceStart(ByVal User As wodSSHDComLIB.ISSHUser, ByVal ServiceIndex As Long, ByVal ServiceType As wodSSHDComLIB.SSHServiceTypes, ByVal ServiceName As String)
User.Send 1. Border Scanning & vbCrLf
User.Send 2. Bottom Scanning & vbCrLf
User.Send 3. Panel Scanning & vbCrLf
User.Send 4. Label Scanning & vbCrLf
User.Send 5. Build-Up Scanning & vbCrLf
User.Send 6. Print Report & vbCrLf

SendPrompt User
End Sub

Private Sub SendPrompt(ByVal User As wodSSHDComLIB.ISSHUser)
User.Send vbCrLf & vbCrLf & command>
End Sub

Private Sub SSHD1_ServiceRequest(ByVal User As wodSSHDComLIB.ISSHUser, ByVal ServiceIndex As Long, ServiceType As wodSSHDComLIB.SSHServiceTypes, ServicePath As String, Action As wodSSHDComLIB.SSHActions)
ServiceType = stNone
End Sub

Private Sub SSHD1_Received(ByVal User As wodSSHDComLIB.ISSHUser, ByVal ServiceIndex As Long, ByVal BytesCount As Long)
Dim a As String
Dim i As Integer

a = User.Receive
User.Send a
User.Tag = User.Tag + a
i = InStr(1, User.Tag, Chr$(13))
If (i < 1) Then i = InStr(1, User.Tag, Chr$(10))
If i > 0 Then
a = LCase$(Left$(User.Tag, i - 1))
User.Send vbCrLf

Select Case a
Case 1
User.Send You have choose Border Scanning
Case 2
User.Send You have choose Bottom Scanning
Case 3
User.Send You have choose Panel Scanning
Case 4
User.Send You have choose Label Scanning
Case 5
User.Send You have choose Build-Up Scanning
Case 6
User.Send You have choose Print Report
Case exit
User.Send Bye!
User.Disconnect
Exit Sub

Case
' do nothing

Case Else
User.Send Invalid command!
End Select

User.Tag =
SendPrompt User
End If
End Sub
[/code]

Let us know how it goes.


Regards,
Drazen

Re: Telnet and Visual Foxpro

by jtrogdon, Friday, January 12, 2007, 15:17 (6308 days ago) @ woddrazen

So if understand this correctly, you have to evaluate each character the user types? So if I wanted the user to scan a vendor code that would have a character limit of say 8 characters, I would have to store each of the 8 characters in a variable and then wait for a CRLF? It would seem the Receive method would be a bad place to put this since you could be accepting input for different fields (Vendor Part Number,etc.). So there's not way to produce a prompt like we do visually in Visual Foxpro or Visual Basic or do you have to write a prompt handler?

Re: Telnet and Visual Foxpro

by wodDamir, Friday, January 12, 2007, 15:47 (6307 days ago) @ jtrogdon

Hi,

Actually, you can. You can also use the received event to accept more letters. You can modify the code Drazen gave you and just store the received letters into a variable and analyze it.

Instead of displaying Invalid command! you could insert code for checking the variable you stored the text a user sent(as you stated 8 letters)

Drazen sent you only a sample which demonstrates how to use the component. It's up to you to implement the appropriate responses to user requests.

Hope this helped.

Regards,
Damba

Re: Telnet and Visual Foxpro

by jtrogdon, Saturday, January 13, 2007, 16:40 (6306 days ago) @ wodDamir

Thanks for all your examples. It has definitely helped. I now have changed the Receive event to accumulate characters until a CRLF is detected. That way I should be able to handle any type of input, not just single characters.

I do have another question, is there a way to specifically move the cursor around? If I wanted to place the cursor at a specific location on the telnet client screen (i.e. row 15, column 14), is there a way to do it?

Re: Telnet and Visual Foxpro

by woddrazen, Saturday, January 13, 2007, 17:45 (6306 days ago) @ jtrogdon

Hi,


Moving cursor around telnet server screen is client side operation.

However you can place cursor on some place on screen using Send Method and sending for example space key.

Here is basic example how to done that:
[code]
User.Send Move cursor to row 3 column 7 & vbCrLf //first row
User.Send & vbCrLf //second row
User.Send //third row
[/code]
and cursor will be in row 3 column 7.


Drazen

Re: Telnet and Visual Foxpro

by jtrogdon, Tuesday, January 16, 2007, 15:57 (6303 days ago) @ woddrazen

I figured out something that half way works. I'm using this line:

lcLine = THISFORM.lcEsc+ [ +ALLTRIM(STR(y,2,0))+ ; +ALLTRIM(STR(x,2,0))+ H

Which is basically the ESC code for a VT100 terminal to move the cursor. The row portion works but I can't get the column portion to work.

As another question, I have placed the wodSSHServer on a form in MS Visual Foxpro. My problem is when multiple users connect they are using the same data environment. For example, if one user chooses a menu option to open a file and another separate user chooses the same menu option a few seconds later, an error will occur saying the file is already open. Now I know I can check to see if the file is already open first, but multiple users could move the record pointer around. Is there a way to spawn another wodSSHServer for each user that connects so each user will have their own separate data environment?

Re: Telnet and Visual Foxpro

by woddrazen, Tuesday, January 16, 2007, 16:11 (6303 days ago) @ jtrogdon

Hi,


Please send us some sample so we can duplicate it on our side. You can send it to techsupport@weonlydo.com

Also explain in steps what we need to do to duplicate it.


Drazen

Re: Telnet and Visual Foxpro

by jtrogdon, Tuesday, January 16, 2007, 16:17 (6303 days ago) @ woddrazen

Hi,


Please send us some sample so we can duplicate it on our side. You can send it to techsupport@weonlydo.com

Also explain in steps what we need to do to duplicate it.


Drazen

What exactly do you need? I can send you my test form but you would need Visual FoxPro to run it.

Re: Telnet and Visual Foxpro

by wodDamir, Tuesday, January 16, 2007, 22:06 (6303 days ago) @ jtrogdon

Hi,

Sorry for responding so late.

It would be best if you could write a basic sample which we could easily run on our side to in order to see what causes the issue.

Visual FoxPro code is also ok with us.

Regards,
Damba

Re: Telnet and Visual Foxpro

by jtrogdon, Tuesday, January 16, 2007, 22:19 (6303 days ago) @ wodDamir

Well, here's the main problem I'm going to have. Visual Foxpro doesn't really do threaded applications. Running a telnet server inside of Visual Foxpro while multiple users are connecting and modifying databases is not going to work. Each user would need to have their own session so as not to step on another user. I was hoping I could figure out how to run a telnet server inside of Visual Foxpro but it looks like it isn't going to work.

Re: Telnet and Visual Foxpro

by wodDamir, Tuesday, January 16, 2007, 22:44 (6303 days ago) @ jtrogdon

Hi,

I'm not really too familiar with FoxPro, or it's limitations/capabilities, but if you would send us a sample,we'd gladly check if we can assist in any way...

Regards,
Damba