Send command does not input text into PuTTY

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Pretzal
Newbie
Posts: 4
Joined: Tue Jan 29, 2013 3:44 pm
Location: Edinburgh

Send command does not input text into PuTTY

Post by Pretzal » Tue Jan 29, 2013 4:01 pm

I've just started out with MS and would like to use it to automate the procedure for logging into my work VPN. My test code looks like this:

Code: Select all

ExecuteFile>C:\Users\Sarah\Documents\VPN access\putty.exe
Wait>.5
SetFocus>PuTTY Configuration
Wait>.1
Send>Cheesecake
Wait>.5
SetFocus>test - Notepad
Wait>.1
Send>Teapot
When this is run, I am left with the notepad file containing 'Teapot', with the PuTTY Configuration behind it with NO text typed in the 'Host Name' text box. The cursor is auto set within this box so setting the focus should be enough.

My boyfriend has a copy of MS and tried out some similar code on his machine (Windows 7), and it appeared to work. I'm running Windows 8, but cannot see how that would cause it to work on his machine but not mine. I've also tried recording using low level conversion, opening PuTTY and typing in the Host Name box, but when recording stops, no Send command appears in the resulting code, just mouse moves and clicks.

Any ideas on how to solve this would be very much appreciated!

BW,

Sarah

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jan 29, 2013 4:48 pm

Hi,

My first observation is that there is insufficient time for Putty to load. I would do this:

ExecuteFile>C:\Users\Sarah\Documents\VPN access\putty.exe
WaitWindowOpen>PuTTY Configuration
SetFocus>PuTTY Configuration
Send>Cheesecake

Now, that is going to Put "Cheesecake" into whatever happens to have focus when Putty is first opened. That might not be what you WANT to receive the text so you might also have to do something to select the correct input, such as Press Tab a few times.

Finally, if Putty is running as admin the above won't work unless you also run Macro Scheduler as admin or stop Putty running as admin:
http://www.mjtnet.com/blog/2012/10/30/c ... -as-admin/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Pretzal
Newbie
Posts: 4
Joined: Tue Jan 29, 2013 3:44 pm
Location: Edinburgh

Post by Pretzal » Tue Jan 29, 2013 6:03 pm

Hi,

Thank you for your response.

Putty was set to run as admin, so I switched this feature off and tried the code. The Putty window comes up but the text does not type in (and the box I want text to be entered in is indeed already selected). I then ran both Putty and MS as administrator and still no luck.

I tried to change the code to bypass the Putty box altogether:

Code: Select all

ExecuteFile>C:\Users\Sarah\Documents\VPN access\putty.exe,uni.hostname.ac.uk
WaitWindowOpen>uni.hostname.ac.uk - PuTTY
SetFocus>uni.hostname.ac.uk - PuTTY
Wait>2
Send>Cheesecake
This brings up a black cmd style box with 'login as:' but 'Cheesecake' does not get typed in... (just pressing keys here does type in things, so it should have worked...).

BW,

Sarah

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Jan 29, 2013 6:57 pm

I've written exactly one script for putty. In that script I'm doing ssh to a local server. But I am skipping the config window by logging in from a putty command line. The script then sends text to the black DOS style box that appears. So I'm certain Putty will accept text from the Send> function

See this page and scroll down to section 3.7 The PuTTY Command Line. Perhaps something there will be helpful. You might be able to save your login configuration then call the configuration on the command line. See section 3.7.3.1 -load: load a saved session.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jan 29, 2013 11:18 pm

I use putty. The code I posted above works. No issues sending text to putty here.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Pretzal
Newbie
Posts: 4
Joined: Tue Jan 29, 2013 3:44 pm
Location: Edinburgh

Post by Pretzal » Wed Jan 30, 2013 12:39 pm

JRL wrote:I've written exactly one script for putty. In that script I'm doing ssh to a local server. But I am skipping the config window by logging in from a putty command line. The script then sends text to the black DOS style box that appears. So I'm certain Putty will accept text from the Send> function

See this page and scroll down to section 3.7 The PuTTY Command Line. Perhaps something there will be helpful. You might be able to save your login configuration then call the configuration on the command line. See section 3.7.3.1 -load: load a saved session.
Thanks for this :). I realise that I can just write one line and I'm logged in with one command without even needing MS. But really the point is that this is the very first thing I thought to try out with the program and unfortunately the text input just isn't working properly for me (it is for some things but not others!). I've been convinced that there is nothing wrong with the code, so there must be something wrong with my computer. Which is a shame, as I was hoping to see if I could integrate it into a much larger MS script.

I still have 24 days remaining on the trial so will see if some kind of Windows 8 update or setting change causes the issue to fix itself in a couple of weeks and will post back if it does :). Also if asked I don't mind sending screenshots/videos of the script being run as proof of the issue.

BW,

Sarah

User avatar
CyberCitizen
Automation Wizard
Posts: 723
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Thu Jan 31, 2013 2:31 am

Hi Sarah,

Can you please post a screen shot of what your trying to automate and what fields your trying to complete. Doesn't have to be a valid host or username / password. Just want to work out what your seeing so we can assist. Then we might be able to assist with the code.
FIREFIGHTER

Pretzal
Newbie
Posts: 4
Joined: Tue Jan 29, 2013 3:44 pm
Location: Edinburgh

Post by Pretzal » Fri Feb 01, 2013 1:07 pm

CyberCitizen wrote:Hi Sarah,

Can you please post a screen shot of what your trying to automate and what fields your trying to complete. Doesn't have to be a valid host or username / password. Just want to work out what your seeing so we can assist. Then we might be able to assist with the code.
Thank you for your response.

Taking the code from Marcus's response, here is the exact situation after F9 is pressed:

http://www.dowce.com/~JZS

As you can see, there is no text input in the Hostname box. Running the same code with Notepad instead of Putty does work however:

http://www.dowce.com/~JZu

This is using v14. The Putty code clearly works on other people's computers, so I'm wondering if you've seen this happen before and know of anything relating to my OS settings or some other thing which may influence the text input like this (it's a brand new Samsung laptop running Windows 8 so apart from remapping CapsLock to Backspace, installing a few things and a couple of very minor settings changes, everything is pretty much still at default).

BW

Sarah

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Feb 01, 2013 2:34 pm

I wonder if the SetFocus line is somehow setting focus to either a different window or at the least is removing focus from the edit field into which you are trying to place "cheesecake".

Or it might just be a timing issue. Your window might not be available to receive the Send> in the hundred thousanth of a second between the moment the window is detected as being open and the moment that Send is placing the text. Place a Wait>1 just ahead of the send

Or instead of send> try setcontroltext>

Replace the send line with:

Code: Select all

SetControlText>Putty*,Edit,1,cheesecake
Let us know if any of these suggestions work.

User avatar
CyberCitizen
Automation Wizard
Posts: 723
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Sat Feb 02, 2013 12:52 am

Try This

Code: Select all

ExecuteFile>C:\Users\Sarah\Documents\VPN access\putty.exe
WaitWindowOpen>PuTTY*
Wait>0.5
SetFocus>uni.hostname.ac.uk - PuTTY
Wait>0.5
Send>Cheesecake
I had a similar issue with Outlook Mail
FIREFIGHTER

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts