[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[网络连接] 为什么批处理模拟按键telnet设备时程序停止执行?

本机telnet到一个交换机,交换机再telnet到下一个设备时,到输入用户名的地方,程序不继续往下执行。为什么啊,,,请各位帮着找一下原因。。。谢了
附件有截图
  1. @echo.
  2. @echo.
  3. @echo ===================================  枫   林 ===================================
  4. @echo.
  5. @echo                                    全自动做数据
  6. @del c:\temp.vbs
  7. @echo on error resume next >>c:\temp.vbs
  8. @echo dim WshShell>>c:\temp.vbs
  9. @echo Set WshShell = WScript.CreateObject("WScript.Shell")>>c:\temp.vbs
  10. @echo WshShell.run"cmd.exe">>c:\temp.vbs
  11. @echo WshShell.AppActivate"c:\windows\system32\cmd.exe">>c:\temp.vbs
  12. @echo WScript.Sleep 200>>c:\temp.vbs
  13. @echo WshShell.SendKeys"telnet 10.10.150.8">>c:\temp.vbs
  14. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  15. @echo WScript.Sleep 100>>c:\temp.vbs
  16. @echo WshShell.AppActivate"telnet.exe ">>c:\temp.vbs
  17. @echo WScript.Sleep 200>>c:\temp.vbs
  18. @echo WshShell.SendKeys"ddddd">>c:\temp.vbs
  19. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  20. @echo WScript.Sleep 200>>c:\temp.vbs
  21. @echo WshShell.SendKeys"ddddd">>c:\temp.vbs
  22. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  23. @echo WScript.Sleep 200>>c:\temp.vbs
  24. @echo WshShell.SendKeys"enable">>c:\temp.vbs
  25. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  26. @echo WScript.Sleep 200>>c:\temp.vbs
  27. @echo WshShell.SendKeys"ddddd">>c:\temp.vbs
  28. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  29. @echo WScript.Sleep 200>>c:\temp.vbs
  30. @set /p oltip=请输入OLT的IP地址:
  31. @set /p boardid=请输入epon-olt接口:
  32. @set /p portid=请输入PON口:
  33. @set /p onuid=请输入onuID:
  34. @set /p mgmvlan=请输入网管vlan:
  35. @set /p onuip=请输入onu-ip:
  36. @set /p gwy=请输入网关:
  37. @set /p vlan=请输入外层vlan:
  38. @set /p vlan1=请输入用户vlan:
  39. @set /a vlan2=%vlan1%+1
  40. @set /a vlan3=%vlan2%+1
  41. @set /a vlan4=%vlan3%+1
  42. @set /a vlan5=%vlan4%+1
  43. @set /a vlan6=%vlan5%+1
  44. @set /a vlan7=%vlan6%+1
  45. @set /a vlan8=%vlan7%+1
  46. @set /a vlan9=%vlan8%+1
  47. @set /a vlan10=%vlan9%+1
  48. @set /a vlan11=%vlan10%+1
  49. @set /a vlan12=%vlan11%+1
  50. @set /a vlan13=%vlan12%+1
  51. @set /a vlan14=%vlan13%+1
  52. @set /a vlan15=%vlan14%+1
  53. @set /a vlan16=%vlan15%+1
  54. @set /a vlan17=%vlan16%+1
  55. @set /a vlan18=%vlan17%+1
  56. @set /a vlan19=%vlan18%+1
  57. @set /a vlan20=%vlan19%+1
  58. @set /a vlan21=%vlan20%+1
  59. @set /a vlan22=%vlan21%+1
  60. @set /a vlan23=%vlan22%+1
  61. @set /a vlan24=%vlan23%+1
  62. @set /p onutype=请输入设备型号(5612,5626):
  63. @if %onutype%==5612 (set /a onu=0)
  64. @if %onutype%==5626 (set /a onu=1)
  65. @set /p onumac=请输入ONU-MAC(杠分):
  66. @echo WshShell.SendKeys"telnet %oltip%">>c:\temp.vbs
  67. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  68. @echo WScript.Sleep 100>>c:\temp.vbs
  69. @echo WshShell.AppActivate"telnet.exe ">>c:\temp.vbs
  70. @echo WScript.Sleep 200>>c:\temp.vbs
  71. @echo WshShell.SendKeys"username">>c:\temp.vbs
  72. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  73. @echo WScript.Sleep 200>>c:\temp.vbs
  74. @echo WshShell.SendKeys"password">>c:\temp.vbs
  75. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  76. @echo WScript.Sleep 200>>c:\temp.vbs
  77. @echo WshShell.SendKeys"enable">>c:\temp.vbs
  78. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  79. @echo WScript.Sleep 200>>c:\temp.vbs
  80. @echo WshShell.SendKeys"config">>c:\temp.vbs
  81. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  82. @echo WScript.Sleep 200>>c:\temp.vbs
  83. @echo WshShell.SendKeys"service-port vlan %vlan% epon %boardid%/%portid% ont %onuid% multi-service user-vlan %vlan1%  tag-transform default">>c:\temp.vbs   ##这是一条service命令
  84. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  85. @echo WScript.Sleep 200>>c:\temp.vbs
  86. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  87. @echo WScript.Sleep 200>>c:\temp.vbs
  88. @echo WshShell.SendKeys"service-port vlan %vlan% epon %boardid%/%portid% ont %onuid% multi-service user-vlan %vlan2%  tag-transform default">>c:\temp.vbs   ##这是一条service命令
  89. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  90. @echo WScript.Sleep 200>>c:\temp.vbs
  91. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  92. @echo WScript.Sleep 200>>c:\temp.vbs
  93. ####上面标记的service命令如果只有一条的话,下面的telnet就可以执行下去,像这样有两条的话,执行到输入用户名的地方程序就停止执行
  94. @echo WshShell.SendKeys"telnet %onuip% 23">>c:\temp.vbs
  95. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  96. @echo WScript.Sleep 200>>c:\temp.vbs
  97. 以下代码执行不去,程序卡住
  98. @echo WshShell.SendKeys"username">>c:\temp.vbs
  99. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  100. @echo WScript.Sleep 200>>c:\temp.vbs
  101. @echo WshShell.SendKeys"password">>c:\temp.vbs
  102. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  103. @echo WScript.Sleep 200>>c:\temp.vbs
  104. @echo WshShell.SendKeys"enable">>c:\temp.vbs
  105. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  106. @echo WScript.Sleep 200>>c:\temp.vbs
  107. @echo WshShell.SendKeys"config">>c:\temp.vbs
  108. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  109. @echo WScript.Sleep 200>>c:\temp.vbs
  110. @echo WshShell.SendKeys"board confirm 0">>c:\temp.vbs
  111. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  112. @echo WScript.Sleep 200>>c:\temp.vbs
  113. @echo WshShell.SendKeys"vlan %vlan1% to %vlan24% mux">>c:\temp.vbs
  114. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  115. @echo WScript.Sleep 200>>c:\temp.vbs
  116. @echo WshShell.SendKeys"y">>c:\temp.vbs
  117. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  118. @echo WScript.Sleep 200>>c:\temp.vbs
  119. @echo WshShell.SendKeys"port vlan %vlan1% to %vlan24% 0/0 %onu%">>c:\temp.vbs
  120. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  121. @echo WScript.Sleep 200>>c:\temp.vbs
  122. @echo WshShell.SendKeys"y">>c:\temp.vbs
  123. @echo WshShell.SendKeys"{ENTER}">>c:\temp.vbs
  124. @echo WScript.Sleep 200>>c:\temp.vbs
  125. @call c:\temp.vbs
复制代码

[ 本帖最后由 fenglin124 于 2010-12-3 22:46 编辑 ]

烦请各位帮忙

上面是困扰我几天的个问题,请各位帮着解决一下,,,谢了。。。

TOP

俺不用 telnet,所以不知道问题出在哪,但:
1:
用那么多@,为什么就不能用一个 @echo off 呢?
2:
@set /p vlan1=请输入用户vlan:
@set /a vlan2=%vlan1%+1
@set /a vlan3=%vlan2%+1
......
@set /a vlan23=%vlan22%+1
@set /a vlan24=%vlan23%+1
完全可以写成:
  1. @echo off&setlocal enabledelayedexpansion
  2. set /p vlan1=请输入用户vlan:
  3. for /l %%a in (2,1,24) do set/a vlan%%a=vlan1-1+%%a
复制代码
寒夜孤星:在没有说明的情况下,本人所有代码均运行在 XP SP3 下 (有问题请发贴,QQ临时会话已关闭)

TOP

嗯,好的,谢谢,,还请各位再帮着看一下

TOP

有人知道是什么原因吗?

TOP

或者可不可以用其它方法实现我全自动的目标呢。。。

TOP

烦啊。。。。。。。。。

TOP

返回列表