Vb.net tst10远程登录脚本

Vb.net tst10远程登录脚本,vb.net,scripting,telnet,Vb.net,Scripting,Telnet,我正在使用此网站()连接到telnet并运行命令。它给了我一些信息。我需要每4秒获取一次信息。我该怎么做?现在它运行,但每次都会重新连接,所以我必须等待它打开连接,这需要比4s多得多的时间。Bat文件: echo off cls if exist r1.txt del r1.txt if exist r2.txt del r2.txt tst10.exe /r:stats.txt /o:r1.txt /m for /f "skip=30 tokens=*" %%A in (r1.txt) do

我正在使用此网站()连接到telnet并运行命令。它给了我一些信息。我需要每4秒获取一次信息。我该怎么做?现在它运行,但每次都会重新连接,所以我必须等待它打开连接,这需要比4s多得多的时间。Bat文件:

echo off
cls
if exist r1.txt del r1.txt
if exist r2.txt del r2.txt
tst10.exe /r:stats.txt /o:r1.txt /m
for /f "skip=30 tokens=*" %%A in (r1.txt) do echo %%A >> r2.txt
del r1.txt
start r2.txt
和统计文件:

192.168.xxx.xxx
WAIT "login:"
SEND "myuser\m"
WAIT "Password:"
SEND "mypass\m"
WAIT ">"
SEND "mycommand\m"
WAIT ">"

使用Powershell通过连接使用csv文件进行编程,我正在使用它对mfd进行重新编程

我有一个文件mfd.txt和一个脚本来读取它

我有一个telnet脚本模板来更改mfd上的设置,powershell脚本为每个mfd创建自定义脚本,并设置dns和主机名参数。运行时,日志文件通过管道传输到一个目录中,以便稍后进行检查

脚本如下:

#Process for updating devices quickly using telnet

#Check file exists
c:
cd 'C:\Resources\Telnet'
cls
$fileisthere = $false
$fileisthere = test-path 'C:\Resources\Telnet\mfds.csv'

if ($fileisthere -ne $true) 
       { 
        ""
        Write-Host ("There is no MFD import list C:\Resources\telnet\mfds.csv")  | out-file -filepath $logfile -force
        ""
        exit 
        }

        Write-Host ("MFD import List is present")


# for each device in devices:
$mfds = import-csv 'C:\Resources\Telnet\mfds.csv'

foreach ($mfd in $mfds) 
{             
#   ping device and check for response
$mfdname = $mfd.name
$mfdip = $mfd.ipaddress
$mfddns1 = $mfd.dns1
$mfddns2 = $mfd.dns2
$mfdhostname = $mfd.serial

""
Write-Host ("Updating device $($mfdname) on IP address $($Mfdip) ")
"" 
("Updating device $($mfdname) on IP address $($Mfdip) ")      |  out-file -filepath $logfile -Append -force

if(!(Test-Connection -Cn $mfdip -BufferSize 16 -Count 1 -ea 0 -quiet))
        {         
        Write-Host ""
        Write-Host ("MFD $($mfdname) is offline or not at this address")
        Write-Host ""                                                         
        ""                                                    |  out-file     $logfile -Append -force
        ("MFD $($mfdname) is offline or not at this address") |  out-file $logfile -Append -force
        ""                                                    |  out-file $logfile -Append -force

        }

else
        {

       #find replace script

# Device is present and add to script header
        $tststring = "$($mfdip) 23"
        $tstfile = "$($mfdname)-$($mfdip).txt"
        $tstlogfile = "$($mfdname)-$($mfdip).log"
        $tststring | out-file $tstfile -force
        type dns.txt >> $tstfile

        $location1 =  "C:\Resources\telnet\$($tstfile)"
        $change1 = get-content $location1
        $change1 | ForEach-Object { $_ -replace "dns 1 server", "dns 1 server $($mfddns1)"} | Set-Content $location

        $location2 =  "C:\Resources\telnet\$($tstfile)"
        $change2 = get-content $location2
        $change2 | ForEach-Object { $_ -replace "dns 2 server", "dns 2 server $($mfddns2)"} | Set-Content $location


        $location3 =  "C:\Resources\telnet\$($tstfile)"
        $change3 = get-content $location3
        $change3 | ForEach-Object { $_ -replace "hostname ether name", "hostname ether name $($mfdhostname)"} | Set-Content $location

        $location4 =  "C:\Resources\telnet\$($tstfile)"
        $change4 = get-content $location4
        $change4 | ForEach-Object { $_ -replace "devicename name", "devicename name $($mfdhostname)"} | Set-Content $location


        # Create variables for update
        Write-Host ("Updating $($Mfdname) on IP Address $($mfdIP) ")

        $parameter1 = "/r:$($tstfile)"
        $parameter2 = "/o:$($tstlogfile)"

        #& cmd tst10 $parameter1 $paremeter2
        write-host ("$($tstfile)  $($tstlogfile)")


        new-item $tstfolder -Type directory
        move-item $tstfile $tstfolder
        move-item $tstlogfile $tstfolder -ErrorAction SilentlyContinue

        }


}

这与VB.NET有什么关系?因为以后我将不得不使用VB.NET处理r2.txt中的这些信息,为什么还要使用telnet程序呢。NET具有套接字支持-您可以在VB.NET中建立telnet连接。(搜索…这里有更多内容-这是C#的,但很容易翻译成VB.NET)但是,如果你想使用这种划线方法,你需要的是
进程。启动
——这将允许你运行批处理文件(作为一个单独的进程)我将在VB.NET中检查telnet连接。如果我能在vb.net应用程序中检索到信息,那就太棒了。谢谢但如果我使用过程。从这个蝙蝠开始,它无论如何都会重新连接,需要4秒以上的时间。