Executing command in Plink from a batch file

你。 提交于 2019-12-23 05:48:09

问题


I want to automate the export process which I take using expdp command in Oracle.

Following is the contents of batch file I have created to open PuTTY.

@echo off

"C:\Program Files\PuTTY\plink.exe" username@Ip_Addr -pw password -m Open_Putty.txt`

Following is the contents of Open_Putty.txt to execute different commands.

echo $ORACLE_SID;

Read oraenv;

But after opening Open_Putty.bat it disappears without showing any output. Please help me with this. I want to set oraenv and run some more commands to take the backup.


回答1:


It's unlikely that plink.exe disappears without showing any output. I assume you execute the batch file from a Windows Explorer or other GUI application, so the Plink console window disappears once Plink finishes (possibly with error) and you cannot read the output (error).

Make sure you execute plink.exe from a console window (typically a cmd.exe) or add pause command to the end of the batch.


Make sure Plink can find the script file (Open_Putty.txt). As you do not specify a path to the file, it has to be located in your current working directory. Safer is to use a full path to the script file:

"C:\Program Files\PuTTY\plink.exe" username@Ip_Addr -pw password -m "C:\path\Open_Putty.txt"

The backtick symbol at the end of the command should probably not be there.


The name "Open PuTTY" is bit confusing. You are not using PuTTY at all. And even if you refer to Plink by "PuTTY", your script file (Open_Putty.txt) is not opening PuTTY nor Plink. It's executing remote commands. So you should better name it export.txt or similar.



来源:https://stackoverflow.com/questions/28134912/executing-command-in-plink-from-a-batch-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!