3

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@1.1.1.1 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 anyone help me to achieve this?

Giacomo1968
  • 58,727

3 Answers3

0

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 :

https://stackoverflow.com/questions/16439039/batch-file-for-putty-psftp-file-transfer-automation

0

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.

rob_st
  • 161
0

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.

https://the.earth.li/~sgtatham/putty/0.70/htmldoc/Chapter7.html#plink

aenagy
  • 11