4

I have some embedded network devices I need to configure. Right now I don't know their IP addresses, and obtaining them is something I can do in PowerShell (I think). Once I get the IP addresses, I'd like to Telnet (and possibly SSH) into them to execute some commands, possibly interpret their feedback, and if I interpret their feedback, eventually save it to a file.

Which I'd have figured PowerShell could do. I haven't found a way yet. Or maybe I'm looking for something too basic and everyone implies that the myriad of tools and discussions obviously can handle something so trivial, and I am just missing it.

Is there a program, PowerShell module, or similar software, to script telnet connections and commands? It doesn't have to literally be telnet.exe, just an interactive shell connection, where I can send commands, interpret results, and then save to a file.

Required features

  • Telnet to an arbitrary port
  • SSH to an arbitrary port
  • Add a delay so the endpoint can process the connection or command
  • Manipulate the responses; pull out relevant info
  • Save to a file
  • Allow for multiple concurrent connections
  • Free, gratis, or low cost software
  • Preferably no install on the machine to runt he scripts (Windows/Power Shell native), portable (self contained), or a complete installer with no other dependencies.
  • Runs on Windows, including Windows Server
  • If not PowerShell, needs robust scripting language capabilities

Thus far I've come across various random "script it with VB" or "script it with this obscure scripting language [that would require all this other software to be installed]". I'd prefer to use Power Shell, but I don't think Power Shell can do all of what I want. I came across the module Get-Telnet, but that isn't working for me (I haven't figured out how to parse the output while still running the script to later save to a file). I found this blog post, and many similar, looking for the same thing.

In my mind, what I am looking for is ridiculously basic, and I should be tripping over qualified softwares, like I would if I wanted an FTP client. It's clear that many people are looking for something similar,

I've come across a lot of recomendations and discussions, and they are grossly over-complicated, or can't see the forest for the trees. Meaning, their webpages go on and on and on about things that are not relevant to my search, nor do I even know what some of the features would be used for, or seem to require gobs of extra software to work. This is clearly a gross oversimplification, painted with a broad brush.

Other relevant links I came across while on my search

2

2 Answers 2

2

I also would have expected you could find something for .NET (and thus PowerShell). And maybe some of those things you already found would work for you if you gave them a fair try.

But the first thought that comes to my mind when you talk about the functionality you want is the classic Unix program expect. This is pretty much the standard way to script a telnet or similar session in Unix.

Lo and behold, there is a .NET "clone" of expect (which was linked to by the Wikipedia article). I also found this Stack Overflow question which turns up a few more leads, including a PowerShell module called Await. I can't say I've used either one of those myself, and both of those projects seem to be dormant (neither one updated in two years), but they might work well enough. More recent is this PowerShell script, but it's comparatively limited in capability. Anyway, you can keep Googling around for stuff, now that you know to look for expect.

If you want something more robust and actively maintained, I recommend ActiveState Expect for Windows. In terms of features and polish, I think it is a good fit for you. The scripting language it's based on (Tcl) is certainly a capable one. (Was this the "obscure" scripting language you were talking about? I guess it's obscure compared to Perl or Python, but it's actually fairly well known and respected in scripting circles.) ActiveState has a reputation for building solid stuff.

If you need the business edition, then it's not what I'd call low-cost (as I write this, it is being offered at the discounted price of $999). The community edition is gratis. It's not clear to me whether the community edition is allowed to be used in a commercial setting. It is billed as being "ideal for community developers or open source projects that are not business or mission-critical", but I can't see where it says it is limited to community developers or open source projects. All I can tell for sure is that the community edition isn't entitled to "professional" support - you have to rely on the forums instead.

1
  • I was a little exasperated while searching and writing the question, and it seemed every new post had a new solution with a different language, telling me I had not yet discovered a good solution. When I came across Expect for the first time, I apparently misunderstood, and thought it was Linux/Unix only. I'll check out Expect, but as of right now, I think I'll just dive in and use the tcpclient cmdlet since I've wasted so much time already. Commented Jul 21, 2017 at 12:05
-2

I know this thread is a few years old but i used tera term years ago to reconfigure all of a companies printers using it's built in macro language.

https://download.cnet.com/Tera-Term/3000-2094_4-75766675.html

1
  • 1
    Can you explain why the proposed software complies with the OP's requirements?
    – Alejandro
    Commented Dec 11, 2019 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.