Can someone help me in sending data to Unix using Winsock through VB6.
I am able to connect but not able to send any commands to Unix.
Any help is highly appreciated.
Thanks in Advance
Below is my code
Private Sub Command1_Click()
Dim username As String
Dim password As String
username = "repoc"
password = "tin$tin"
cmd1 = "mkdir JJJJ"
If Winsock1.State = sckConnected Then
Winsock1.SendData username + vbCr
Winsock1.SendData password + vbCr
Winsock1.SendData cmd1 + vbCr
End If
End Sub
Private Sub Command2_Click()
If Winsock1.State = sckConnected Then
Winsock1.SendData "mkdir JJJJ" + vbCr
'Winsock1.SendData "touch a.txt"
End If
End Sub
Private Sub Form_Load()
Dim bRet() As Byte
bRet = AsciiToUTF8("hello")
Debug.Print UBound(bRet)
Debug.Print UTF8ToAscii(bRet)
Winsock1.RemoteHost = "10.2.16.192"
Winsock1.RemotePort = 23
Winsock1.Connect
'Winsock1.Listen
End Sub
Private Sub Winsock1_Connect()
'MsgBox "Connected"
'Winsock1.SendData "mkdir JJJJ" + vbCr
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Error has occured"
End Sub
Public Function AsciiToUTF8(InputStr As String) As Byte()
Dim bytSrc() As Byte
Dim bytDest() As Byte
Dim i As Long
bytSrc = InputStr
ReDim bytDest(UBound(bytSrc) \ 2)
For i = 0 To UBound(bytDest)
bytDest(i) = bytSrc(i * 2)
Next
AsciiToUTF8 = bytDest
End Function
Public Function UTF8ToAscii(ByRef InputByt() As Byte) As String
Dim bytDest() As Byte
Dim i As Long
ReDim bytDest(UBound(InputByt) * 2 + 1)
For i = 0 To UBound(InputByt)
bytDest(i * 2) = InputByt(i)
Next
UTF8ToAscii = CStr(bytDest)
End Function
I am able to connect but not able to send any commands to Unix.
Any help is highly appreciated.
Thanks in Advance
Below is my code
Private Sub Command1_Click()
Dim username As String
Dim password As String
username = "repoc"
password = "tin$tin"
cmd1 = "mkdir JJJJ"
If Winsock1.State = sckConnected Then
Winsock1.SendData username + vbCr
Winsock1.SendData password + vbCr
Winsock1.SendData cmd1 + vbCr
End If
End Sub
Private Sub Command2_Click()
If Winsock1.State = sckConnected Then
Winsock1.SendData "mkdir JJJJ" + vbCr
'Winsock1.SendData "touch a.txt"
End If
End Sub
Private Sub Form_Load()
Dim bRet() As Byte
bRet = AsciiToUTF8("hello")
Debug.Print UBound(bRet)
Debug.Print UTF8ToAscii(bRet)
Winsock1.RemoteHost = "10.2.16.192"
Winsock1.RemotePort = 23
Winsock1.Connect
'Winsock1.Listen
End Sub
Private Sub Winsock1_Connect()
'MsgBox "Connected"
'Winsock1.SendData "mkdir JJJJ" + vbCr
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Error has occured"
End Sub
Public Function AsciiToUTF8(InputStr As String) As Byte()
Dim bytSrc() As Byte
Dim bytDest() As Byte
Dim i As Long
bytSrc = InputStr
ReDim bytDest(UBound(bytSrc) \ 2)
For i = 0 To UBound(bytDest)
bytDest(i) = bytSrc(i * 2)
Next
AsciiToUTF8 = bytDest
End Function
Public Function UTF8ToAscii(ByRef InputByt() As Byte) As String
Dim bytDest() As Byte
Dim i As Long
ReDim bytDest(UBound(InputByt) * 2 + 1)
For i = 0 To UBound(InputByt)
bytDest(i * 2) = InputByt(i)
Next
UTF8ToAscii = CStr(bytDest)
End Function