找回密码
 加入
搜索
查看: 3591|回复: 2

[网络通信] telnet登陆 ROS 并且执行语句

[复制链接]
发表于 2011-3-30 23:38:45 | 显示全部楼层 |阅读模式
本帖最后由 haodd 于 2011-3-31 15:30 编辑

貌似论坛有问题了
终于可以贴上代码了 pcbar
在官方论坛也找到类似的

但是在我这里应用都不行撒  返回 ? ? ? ? 四个问号
Global $host, $port, $delay, $user, $pass, $sk, $ack

$host = "192.168.1.1"
$port = 23
; miliseconds to wait before sending/receiving something
$delay = 300 ; compensates network/internet delays
$user = ""
$pass = ""

TCPStartup()
$sk = TCPConnect($host, $port)

;if invalid socket
If $sk = -1 Then
MsgBox(0, "", "Cannot connect")
Exit
EndIf

; message from device
Sleep($delay)
$ack = TCPRecv($sk, 150)
TrayTip("", $ack, 10)

; verifying the correct answer
If StringInStr($ack, "wl500gp login") >= 1 Then
; if the string is correct then we send user
Sleep($delay)
TCPSend($sk, $user & @CRLF)
Sleep($delay)
$ack = TCPRecv($sk, 80)
TrayTip("", $ack, 10)
; and password
Sleep($delay)
TCPSend($sk, $pass & @CRLF)
Sleep($delay)
$ack = TCPRecv($sk, 80)
TrayTip("", $ack, 10)
Else
MsgBox(0, "", "Cannot connect")
Exit
EndIf

; verifying the answer of the device (the prompt that it returns after receiving user and password)
If StringInStr($ack, "root]$") = 0 Then ; attention, this string is specific
MsgBox(0, "Error", "Access denied")
Exit
EndIf

; now you can send some commands
Sleep($delay)
TCPSend($sk, "ps" & @CRLF)
Sleep($delay)
$ack = TCPRecv($sk, 2000)
MsgBox(0,"Running processes", $ack)

TCPCloseSocket($sk)
TCPShutdown()
Exit
 楼主| 发表于 2011-3-31 15:31:02 | 显示全部楼层
可以贴出代码了 顶起先    求 能用的
 楼主| 发表于 2011-4-1 10:27:55 | 显示全部楼层
http://dotnettelnet.sourceforge.net/

新搜集的 dll

自己再顶一下
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 11:09 , Processed in 0.084602 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表