Automate putty via batch and execute a command

Super User Asked by Asheesh Kubde on January 12, 2021

I use putty everyday to login to a Linux session and execute some commands.

Now since I have a thought to automate this process, I would like some help to complete this process.

I have made a batch file which contains the below commands:

Start putty.exe [email protected] 22 -pw 1234

Using this script I am able to open a putty session.

Now I want it execute my next command as well:

ps -eaf|grp sometext

Can you please help me to achieve this?

It’s a huge challenge for me.

3 Answers

Have you looked at PuTTY's Plink command?

Quoting from the documentation:

Plink is a command-line connection tool similar to UNIX ssh. It is mostly used for automated operations, such as making CVS access a repository on a remote server.

Answered by aenagy on January 12, 2021

You should use a server-login script. On your server, create a .bash_profile-file in your home folder (if it isn't already present) and put in the scripts there. Usually your server is set up to run the .bash_profile login script every time the user logs in.

To get to know where your home folder is, type echo $HOME.

Maybe you also want to set up SSH, so that you don't have login each time. I'm not sure how secure it is to pass login-credentials through the batch-file.

Answered by rob_st on January 12, 2021

I think you can call another script inside this existing batch file containing further commands that you want to execute .

I just had a look at this , just something similar to what you are trying :

Answered by ganesh kadam on January 12, 2021

Add your own answers!

Related Questions

Ubuntu Mate freezes after user login

1  Asked on November 9, 2021 by nathaniel-graham


Keep getting “Index out of range” error

1  Asked on November 9, 2021 by jerunenchaussettes


How does Iconv handle endianness?

1  Asked on November 9, 2021


MSI BIOS Distorted

0  Asked on November 9, 2021 by karma-blackshaw


Network problems using WSL2

3  Asked on November 7, 2021 by lars-rdal


With Bash + iTerm2, how to name tabs?

16  Asked on November 7, 2021


How to increase the font size for Skype on OS X?

4  Asked on November 7, 2021 by user2225404


How can I stop photos I download from popping up in Preview?

2  Asked on November 7, 2021 by mike-mercer


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir