+ Reply to Thread
Results 1 to 5 of 5

Macro to open Putty and paste contents

  1. #1
    Registered User
    Join Date
    05-29-2018
    Location
    India
    MS-Off Ver
    2016
    Posts
    2

    Macro to open Putty and paste contents

    i,

    I'm new to excel macro, and I have this big requirement to complete..

    Requirement:

    1. Connect to putty through excel macro - the login details should betaken from cells in excel.
    2. Run few commands in putty - these commands also will be added in the excel macro.
    3. Results of the commands needs to be displayed in the excel.

    I have this below but it opens when i double click the device name in the cell.
    Please Login or Register  to view this content.
    Drawbacks in this is it is not taking the the password from cells in excel and not displaying the output in excel


    Basically, on click of a button, it should get connected to putty and run the commands and results should be displayed.

    Any other solution also accepted

    Any help would be appreciated...!!!

    Thanks,
    Last edited by alansidman; 08-20-2019 at 09:35 AM.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,882

    Re: Macro to open Putty and paste contents

    I'd recommend using plink. It's commandline interface to the PuTTY back ends, and easier to work with. PuTTY is more of interactive GUI.

    Documentation for plink:
    https://the.earth.li/~sgtatham/putty.../Chapter7.html

    Sample Code attached: "hello, world" where A1 holds username and B1 holds password.

    Otherwise try following example in link for PuTTY (by John_w)
    https://www.mrexcel.com/forum/excel-...excel-vba.html

    Edit: If you want pline returned to Excel. You'll need to add counter and use that as row index for range that you want to put the value into.
    Attached Files Attached Files
    Last edited by CK76; 05-29-2018 at 10:25 AM. Reason: See Edit:
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    05-29-2018
    Location
    India
    MS-Off Ver
    2016
    Posts
    2

    Re: Macro to open Putty and paste contents

    Hi I have this.but when ever i save this code and double click where ever in the sheet it tries to open the Putty ssh with the value in the cell.
    But what i require is like only

    1. A2:A16 these ranges if we double click it open ssh with Putty . Anywhere else if we double click it should not open putty
    2. For Password it should take from the value in cell A1 because everyday we get new password so i paste the password in the A1. Username is constant so no issues
    Can some one help to achieve above by editing the below script
    ================================================================
    Please Login or Register  to view this content.
    ================================================================
    Last edited by alansidman; 08-20-2019 at 09:36 AM.

  4. #4
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    199

    Re: Macro to open Putty and paste contents

    I hope my reply is informative, and also leads to the additional answers.

    Like already mentioned, pLink is the command line way to do this, as puTTY is designed for interactive use.

    In a previous position, I was able to use SecureCRT which has its own internal scripting language. I could pass a list of commands through that quite nicely (with all kinds of prompt waiting for commands to complete). I could even have the SecureCRT code do it's own conditional switching, when output wasn't as expected. If I could talk my current employer into buying SecureCRT, I'd be doing it that way.

    Here is how I've been able to do this:
    Please Login or Register  to view this content.
    I have a few problems with this myself...
    • I must exit out of the shell to be able to see and manipulate the results.
      • If I want to do something in response to the output, I have to go back in with new commands.
      • This is not interactive by any means. If one of these commands hangs, it all dies.
    • My bash shell assumes a tty with ANSI features, so the output has escape codes that are meaningless to pLink (but might be able to be ignored).


    It would be great if there is some kind of dynamic way to communicate to plink, or maybe an ssh environment that just runs in VBA.

    So, I hope this helps, and gets more complete answers for us all.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    Re: Macro to open Putty and paste contents

    @imabbas_90

    Code Tags Added
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA to open MS Outlook and paste cell contents into body
    By CheekyDevil in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2017, 02:41 AM
  2. Trying to open Putty from Excel which contains list of servers.
    By prabsriv in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2017, 09:55 AM
  3. Need Macro to open PuTTY and connect to a linux server
    By balajinatarajan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-16-2016, 01:24 PM
  4. [SOLVED] Find the next open column to the right and paste contents
    By TheScott in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-16-2015, 01:07 PM
  5. Replies: 1
    Last Post: 06-15-2014, 07:26 PM
  6. Putty macro help
    By poodlesplumbs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-31-2013, 01:34 AM
  7. [SOLVED] Open multiple text files and paste contents to single cell
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2005, 12:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1