telnet到不同的IP并运行命令

发布于 2024-08-07 01:11:01 字数 280 浏览 5 评论 0原文

我不确定这是否可能。

我正在寻找一种方法来告诉 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凶凌 2024-08-14 01:11:01

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 with ssh. 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.

灯角 2024-08-14 01:11:01

我认为您正在寻找 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.

恍梦境° 2024-08-14 01:11:01

不是为了吹嘘我自己,但你也许可以扭曲我的个人应用程序(注意:抱歉,我已经删除了这个。)为此目的。

目前没有其他文档比该页面上的内容要少,并且没有公共源代码(尽管我一直想了解这一点,如果您感兴趣的话明天会解决),但我很乐意回答任何问题。

也就是说,任何 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文