从批处理文件中执行 Plink 中的命令 [英] Executing command in Plink from a batch file

查看:88
本文介绍了从批处理文件中执行 Plink 中的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Oracle 中使用 expdp 命令自动执行导出过程.

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

以下是我创建的用于打开 PuTTY 的批处理文件的内容.

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

@echo 关闭

C:\Program Files\PuTTY\plink.exe"用户名@Ip_Addr -pw 密码 -m Open_Putty.txt`

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

以下是执行不同命令的Open_Putty.txt的内容.

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

回显 $ORACLE_SID;

echo $ORACLE_SID;

读取oraenv;

但是在打开Open_Putty.bat 后,它消失了,没有显示任何输出.请帮我解决一下这个.我想设置 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.

推荐答案

plink.exe 不太可能消失而不显示任何输出.我假设您从 Windows 资源管理器或其他 GUI 应用程序执行批处理文件,因此一旦 Plink 完成(可能有错误),Plink 控制台窗口就会消失,并且您无法读取输出(错误).

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).

确保从控制台窗口(通常是 cmd.exe)执行 plink.exe 或将 pause 命令添加到批次.

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

确保 Plink 可以找到脚本文件 (Open_Putty.txt).由于您没有指定文件的路径,它必须位于您当前的工作目录中.更安全的是使用脚本文件的完整路径:

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.

Open PuTTY"这个名字有点令人困惑.您根本没有使用 PuTTY.即使您通过PuTTY"来引用 Plink,您的脚本文件 (Open_Putty.txt) 也不会打开 PuTTY 或 Plink.它正在执行远程命令.因此,您最好将其命名为 export.txt 或类似名称.

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.

这篇关于从批处理文件中执行 Plink 中的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆