Jump to content

Putty commands through AutoIT


Jason86
 Share

Recommended Posts

Hi,

I would like to automate Putty commands whereby it will select my saved telnet session (so open Putty Configuration and select session) and afterwards it will open the Putty-prompt and will do next commands:

<Enter>
ACCESS <Enter>
'UserName' <Enter>
SET Priv <Enter>
'Password' <Enter>
LOG PORT ALL <Enter>

And close Putty

Kind of new in AutoIT so all help is welcome !

 

Thanks in advance,

Regards,

 

Link to comment
Share on other sites

  • Moderators

Agree that plink is probably your best bet. I do a lot in putty sessions for customers, and use the following as a framework:

Local $sEXE = @MyDocumentsDir & "\PuTTY\PLINK.EXE"
Local $sUser = " -l root"
Local $sPass = " -pw Password1"
Local $sCommand = " esxcli storage vmfs unmap -l "

    For ...
        ShellExecute($sEXE, " -ssh " & $aRange1[$a][1] & $sUser & $sPass & $sCommand & $aRange1[$a][0]) ; - Pulls datastores from excel range and runs vmfs unmap
    Next

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Depending on your circumstances you may also want to look at using ssh keys rather than embedding your username/password (care where you put the private key!).

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Link to comment
Share on other sites

36 minutes ago, SlackerAl said:

You might want to check out plink.exe (command line putty) which works better for non-interactive telnet operations and can be run from a batch file.

so something like : putty.exe -load “session name” but how to start this session and run the commands ? :s

Link to comment
Share on other sites

13 minutes ago, SlackerAl said:

:D Thanks SlackerAl , I found this on the net:


\path\to\putty.exe -load "[Sessionname]" -l [user] -pw [password] -m C:\path\to\commands.txt

 

and in commands.txt I'll put the commands mentioned here beneath :

<Enter>
ACCESS <Enter>
'UserName' <Enter>
SET Priv <Enter>
'Password' <Enter>
LOG PORT ALL <Enter>

Thanks !

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...