9

These are the things I need to do:

  1. Open putty.exe
  2. Enter username and password.
  3. Run a shell script.

I am using UFT (VB Scripting). I am able to open PuTTY but not able to enter username and password or run any commands using UFT.

Is there any other way I can achieve this? I have searched it and found that we can use Plink. Then the problem would be that the whole team will have to install Plink for that purpose. And that is not possible.

Thanks in advance.

3 Answers 3

11

PuTTY has the -m switch, that you can use to provide a path to a file with a list of commands to execute:

putty.exe [email protected] -m c:\local\path\commands.txt

Where the commands.txt will, in your case, contain a path to your shell script, like:

/home/user/myscript.sh

Though for automation, your better use the Plink command-line connection tool, instead of the GUI PuTTY application, as you have already found out. The Plink is a part of PuTTY package, so everyone who has PuTTY should have Plink too.

The Plink (plink.exe) has the same command-line arguments as PuTTY. And in addition to those, you can specify your command directly on its command like:

plink.exe [email protected] /home/user/myscript.sh

or using its standard input

plink.exe [email protected] < c:\local\path\command.txt

(of course, you will use redirection mechanism of your language, instead of the <).


Note that providing a command using the -m switch or directly on command-line implies a non-interactive mode, while using the standard input uses an interactive mode by default. So the results or behavior may differ. Use the -t and -T switches to force the interactive and the non-interactive mode, respectively.

Sign up to request clarification or add additional context in comments.

Comments

0

You can add cmd arguments when you launch putty directly;

start C:\Users\putty.exe -load "server" -l userID -pw Password -m commands.txt

Can you not request the user name and pass prior and pass this along to the executable?

1 Comment

Yes, that is what I am going to do. Get username and password and pass it to putty. But that is not the issue here. Thing is that I am not able to run any commands using UFT. Error I am getting is that "putty is not a window object".
0

To run a single remote command or short series of commands is even easier by using the plink -batch flag instead of needing a script file. For example to show the OS name and a directory listing, do this:

plink user@host -pw password -batch uname;ls

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.