我正在尝试在Windows的命令提示符中使用Putty \ Plink在HP ProCurve 2510G-24交换机上自动启用/禁用端口。最终,我希望能够运行计划任务来运行批处理文件,从而启用\禁用交换机上的任何端口。
我已经设法完成以下任务:-Putty \ Plink-在交换机上手动设置“ tty = none”-使用echo命令
将plink与-batch和-ssh标志一起使用,tty = none,并且至少具有“空格” /任何字符的第一个回显使我登录并通过“按任意键继续...”提示非互动地。 (这是我发现我们都遇到了麻烦!!)
从理论上讲,显示的第二个命令是可行的,但是我的输出是“接口'未被识别为内部或外部命令,可操作程序或批处理文件。”
-m值显然不适用于将命令从文本文件传递到HP,看来,当不使用-m标志且-N / -s是Plink时,Plink可以启动shell。它挂了。
第三个是应该起作用的,但似乎无法传递命令:config interface 2 enable
C:\Windows\system32>echo /config| plink.exe -batch -ssh admin@192.168.1.2 -pw 12345678 -v
Looking up host "192.168.1.2" for SSH connection
Connecting to 192.168.1.2 port 22
We claim version: SSH-2.0-PuTTY_Release_0.73
Remote version: SSH-2.0-OpenSSH_3.7.1p2
Using username "admin".
Sent password
Access granted
Opening main session channel
Opened main channel
Allocated pty
Started a shell/command
ProCurve J9279A Switch 2510G-24 Software revision Y.11.12
Copyright (C) 1991-2009 Hewlett-Packard Co. All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and Computer Software clause at 52.227-7013.
HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303
Press any key to continue
tty=none DC PC SW 2510G24 1# config
tty=none DC PC SW 2510G24 1(config)#
C:\Windows\system32>echo.config && interface 16| plink.exe -batch -ssh admin@192.168.1.2 -pw 12345678
config
'interface' is not recognized as an internal or external command, operable program or batch file.```
C:\Windows\system32>plink.exe -batch -ssh admin@192.168.1.2 -pw 12345678 [-N/-s] -m c:\scripts.[txt/bat]