telnet到不同的IP并运行命令
我不确定这是否可能。
我正在寻找一种方法来告诉 telnet 使用某个 IP 地址登录,然后运行命令,其中命令根据用户的 MAC 地址而变化。
基本上是这样的:
- 告诉 telnet 使用 xxxx 作为 IP 登录并输入正确的用户名和密码
- 告诉 telnet 运行命令(基于用户的 MAC 地址),这些命令可以根据您想要查看的用户统计信息进行更改,例如: show macaddress
- 将输出导出到记事本
- close
I'm not sure if this is possible or not.
What I'm looking for is a way to tell telnet to use a certain IP address to log into and then run commands where the commands change based on a user's MAC address.
Basically it would be:
- tell telnet to use x.x.x.x as the IP to log into and put in the correct username and password
- tell telnet to run commands (based on the user's MAC address) that can change based on which user stats you want to see, for example: show macaddress
- export the output to notepad
- close
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
expect 可以做到这一点。如果您没有 Tcl,但有 Python,请尝试 Pexpect。
如果您只想运行一个命令,请使用 ssh(它允许您登录、运行命令,并且将返回命令的错误代码,因此您也可以处理错误)。
如果您想运行多个命令,请编写一个脚本,使用
scp
将该脚本复制到另一端,然后使用ssh
执行该脚本。我已经使用这种方法取得了巨大成功,构建了一个简单的蜘蛛,它可以运行脚本来收集大量主机的系统信息。expect can do this. If you don't have Tcl but Python, try Pexpect.
If you just want to run one command, use
ssh
(which allows you to log in, run a command and which will return with the error code of the command, so you can handle errors, too).If you want to run more than a single command, write a script, use
scp
to copy that script to the other side and then execute the script withssh
. I've used this approach with great success to build a simple spider that could run a script to gather system information over a large number of hosts.我认为您正在寻找 expect (它会自动执行此类交互式应用程序)。这是来自expect权威的免费章节,书“探索Expect ”。
如果是通过互联网,您还应该使用 SSH。 Telnet 是不安全的,因为它是纯文本协议。
I think you're looking for expect (it automates these kind of interactive applications). Here is a gratis chapter from the authority on expect, the book "Exploring Expect".
Also you should use SSH if this is over the internet. Telnet is insecure as it's a plain text protocol.
不是为了吹嘘我自己,但你也许可以扭曲我的个人应用程序(注意:抱歉,我已经删除了这个。)为此目的。目前没有其他文档比该页面上的内容要少,并且没有公共源代码(尽管我一直想了解这一点,如果您感兴趣的话明天会解决),但我很乐意回答任何问题。也就是说,任何 MUD 客户端也可以用于相同的用途。
Not to blow my own horn, but you may be able to twist a personal app of mine (note: Sorry, I've removed this.) to this end.There's currently no documentation other than what is on that page and no public source code (though I've been meaning to get onto that, and will work that out tomorrow if you're interested), but I'd be happy to answer any questions.That said, any MUD client could be turned to the same use too.