Currently I'm doing this: start putty.exe
, input remote server IS and select SSH login, then input server username and password. Then I have to enter sqlplus
to enter into database, next I put database user and password and run select query. Get output logs on my PC.
I want to automate the process using Plink or any other tool.
As you already know, you can use
plink
(from PuTTY package) to automate remote command execution.The
plink
has the command-line switch-m
, that you use to specify a local file with the command to execute on the remote server.See Using the command-line connection tool Plink
The next step is to automate the remote command.
I do not know
sqlplus
. But from A Using SQL Command Line, I assume the command (to be saved into the local filecommand.txt
) is like:Where the
query.txt
is a remote file with the query to execute on the server.Finally to save the query output, redirect the
plink
to a local file (results.txt
):If you are executing one command only, you can specify it directly on the
plink
command-line, avoiding the separate script file: