How to open putty using batch and login then execute list of commands on bash

shareef picture shareef · May 2, 2016 · Viewed 45.3k times · Source

I have a Sun OS server with oracle configured on it ; with database 11g i want to take backup , now am connecting to terminal using ssh on putty console but , what i need is finding a way to make it possible to connect using batch to ssh to the server then login then login to oracle then take the backup, is that possible and how.

Answer

shareef picture shareef · May 2, 2016

If you really want to use putty to do this you can use the below in your command prompt in Windows(this will open the putty and its terminal and execute the passed argument in you text file):

putty.exe plink  -ssh -load profileName -l username -pw password -m commandPath -t

Or

putty.exe -ssh username@ip -pw password -m commandPath

e.g:

putty.exe -ssh [email protected] -pw rootzpass -m c:\commands\mycommands.txt

Where profileName is the profile saved in putty and the commandPath is your local directory text file containing the commands you want to execute and the username is the server user and ip is the IP address for the server , the password is your server password then you can put whatever commands you want in your textFile.

Reference the.earth putty documentation