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 abc@ 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.


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 :



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.

  • 1
    That would cause the script to run on every log in , and even any time a new shell is started (via screen, local login, etc). If this is a daily task, why not just set a cron job on the remote machine itself to do it? – ivanivan Aug 14 '17 at 1:08

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.


  • This suggestion looks promising, but have you looked at it?   We prefer answers that are answers, not just suggestions.   Can you explain how the OP can use plink to solve his problem?   Please do not respond in comments; edit your answer to make it clearer and more complete. – Scott Oct 14 '18 at 0:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.