viewpoint-particle

Author Topic: PUTTY - WinBatch to automate password changes  (Read 254 times)

ninedd

  • Newbie
  • *
  • Posts: 2
PUTTY - WinBatch to automate password changes
« on: August 23, 2019, 08:01:21 pm »
Hi.  I'm trying to use WinBatch to automate passwords changes on some embeded Linux boards. I should add - these are not normal Linux (so no normal Linux tools, no perl, no python, etc, etc) and they have a TUL - a Text User Interface - but no real command line exactly.

So, how we would manually change a password is that we'd log into a router with Putty (SSH) and then we'd hit ALT-S to get the 'System' menu to pop down, then I'd hit 'p' key to go to the password item of that menu, and then hit 'y' to answer the popup question 'Do you want to change the password?', and so on through the password change process.

So - I was thinking that we could use a program like WinBatch to automate a mass password change, so that I hopefully can just give WinBatch a list of IP addresses, and it can log into each board and change the passwords by simulating keystrokes.  BUT, I can't figure out how to get WinBatch to do this sadly.

My WinBatch script IS launching Putty properly:

Run ("putty", "admin@10.1.2.3 -pw 1234")

but after that, anything I've tried with 'SendKey' or 'SendKeysto' lines of the script, nothing seems to to do anything in my open putty session. :(

SendKeysto ("~putty", "!s")
SendKeysto ("~putty", "p")
SendKeysto ("~putty", "y")


So with the above, when it hits line 2, I get a:

'1045 WinActivate: Window not found' STOP error.


Perhaps there is a simpler way to accomplish these password changes - I'm pressed for time and WinBatch seemed like a straight forward way to accomplish this across a few hundred boards - but now I'm stuck and not sure why SendKey or SendKeysto it isn't working.

td

  • Tech Support
  • *****
  • Posts: 3103
    • WinBatch
Re: PUTTY - WinBatch to automate password changes
« Reply #1 on: August 26, 2019, 08:43:32 am »
Mostly observation with a few suggestions and probably not all that useful since you are in a hurry.

  • The error message is self-explanatory so you the analysis.wbt may be able to help you to determine the correct Window name to use with your session window.  The script is in your WinBatch examples folder.
  • Sending keystrokes is the approach of last resort when other solutions don't present themselves.  This is particularly true when working with remote hosts.
  • The Tech Database article and sample here: https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/Winsock/Samples~From~Users+Telnet~Example~from~Chuck~Chopp.txt, illustrates using telnet to access a remote host.  Not sure how useful it is in this case and it does have a bit of a learning curve.
  • If your remote host uses HTML for its UI, you could consider using one of the several WinBatch techniques for automating Web page interaction.

I suspect that there is an easier way to perform your task using WinBatch but can't think of what it might be at the moment.  Perhaps some other member of the forum will chime in with an idea.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

ninedd

  • Newbie
  • *
  • Posts: 2
Re: PUTTY - WinBatch to automate password changes
« Reply #2 on: August 26, 2019, 01:02:08 pm »
OK, thank you.  I used 'analysis' to find out the name of the window.  I thought that Sendkey could just use the last active window, and I assumed that if I had just 'Run' the Putty program - that it would likely be the active window... but I guess not.  Thank you, your assistance helped.

However - I am still kinda in a pickle here, and I'm wondering if I can hire someone to bail me out. :)  I need to change passwords on 100's of devices all at once, and I need to to it SOON due to a security issue.  So, I'm wondering if I can hire someone to write this program for me, rather than taking the few days to figure out how to accomplish it on my own?  IS that a paid service I can pay WinBatch for, or are their WinBatch freelancers who are for hire?

Thank you.

td

  • Tech Support
  • *****
  • Posts: 3103
    • WinBatch
Re: PUTTY - WinBatch to automate password changes
« Reply #3 on: August 27, 2019, 06:40:41 am »
Your quickest solution may be to try using WinMacro to record a keystroke and mouse move base script.  You could then edit the script to condense it down to the essentials.   WinMacro can be found in the PopMenu menu's right-hand side menu items.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

  • Sr. Member
  • ****
  • Posts: 276
Re: PUTTY - WinBatch to automate password changes
« Reply #4 on: August 28, 2019, 10:53:30 pm »
The problem with your request for someone to do work for hire to solve your issue is that nobody has any idea what kind of "board" you're actually working with.

And nobody will have any idea unless they can actually see it and touch it.

Which means that there's no way you're going to get this problem solved (in the manner you seem to prefer - namely, hiring someone to do it) unless you are willing to fly them out to your site (wherever that may be) and let them see what you're working with.  Are you willing to do that?

P.S. FWIW, one of the endearing features of PuTTY is the weird capitalization of its name.  One of the endearing features of WinBatch is the fact that window name matching is case sensitive.  I leave it to you to connect the dots between these two endearing features.

td

  • Tech Support
  • *****
  • Posts: 3103
    • WinBatch
Re: PUTTY - WinBatch to automate password changes
« Reply #5 on: August 29, 2019, 07:43:02 am »
Based on the OP's response he seems to have figured out the window title/text issue.  However, the OP stated, "that it would likely be the active window... but I guess not". This suggests the OP missed the point a bit - the WinActive error is because SendKeysTo needs to make sure the target windows has the input focus but it can't if the text is not correct.  However, the error does not mean that the target window was not the active window (the window with the input focus).

The OP also states that using the Analysis.wbt script helped but still wanted someone else to write the script.  That would indicate that the OP still has some unresolved issue but does not provide any additional information about what that issue might be.  If the OP had been able to provide a little more information, board members may have been able to provide a bit of assistance that may (or may not) have enabled the OP to finish the project in a much more timely fashion than going through some kind of hiring process.       
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

pguild

  • Newbie
  • *
  • Posts: 29
Re: PUTTY - WinBatch to automate password changes
« Reply #6 on: September 23, 2019, 07:41:30 pm »
What happened to the good old days when people would see my listing on Winbatch and hire me to do Winbatch jobs? I got some very nice gigs that way!  From Whirlpool Corp., Siemens, and an owner of a Subway Restaurant who wanted a way to check sales made by various cashiers while sitting at home.

I am wondering why the PUTTY person not directed to the Winbatch Professionals Page?  Or does it still exist?

td

  • Tech Support
  • *****
  • Posts: 3103
    • WinBatch
Re: PUTTY - WinBatch to automate password changes
« Reply #7 on: September 24, 2019, 09:59:57 am »
The consultant page doesn't exist for a reason.  If you are interested in performing WinBatch consulting work, you could send a private message to any forum user that solicits outside consulting.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

  • Sr. Member
  • ****
  • Posts: 276
Re: PUTTY - WinBatch to automate password changes
« Reply #8 on: September 25, 2019, 12:05:09 pm »
(I'd be curious to know what that reason is...)

Anyway, the point is that people are more comfortable if they think they have sought you out than if it looks like you are "stalking" them.  In fact, it is a pretty good rule on the modern inter-web that if anyone you don't know tries to contact you, just ignore it.  Don't even think about it; just ignore it.

Sad, but true.

td

  • Tech Support
  • *****
  • Posts: 3103
    • WinBatch
Re: PUTTY - WinBatch to automate password changes
« Reply #9 on: September 25, 2019, 07:38:15 pm »
I think you missed the point a bit.  If someone openly solicits a consultant on this form, it can hardly be considered stalking to respond to the solicitation. 

There are two reasons for not having a consultant page.  The first reason is that we don't have the resources to even minimally vet a potential consultant.  Even if a disclaimer is added, the presents on the WinBatch site could be interpreted as an endorsement.  The second reason is that most of the existing links contact information on our consultant page was outdated and to entities that are no longer exist as providers of WinBatch consulting services.  The page was basically little more than deceptive marketing.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade