简体   繁体   English

如何连接到 SQLPLUS 并在 ssh unix 中运行 SQL 脚本?

[英]How to connect to SQLPLUS and run SQL script within ssh unix?

I have the following bash script:我有以下 bash 脚本:

#!/bin/bash

set command "sqlplus -s user/password@tns"

ssh -t  test@192.168.94.139 $command

Now, I want to run te following sql script (which is on the other device I'm accessing):现在,我想按照 sql 脚本(在我正在访问的另一台设备上)运行 te:

/usr/mikael/myfile.sql

How is the best practice to run the script from that path?从该路径运行脚本的最佳做法是什么?

I've seen a suggestion to add "/usr/mikael/myfile.sql" to the end of the command, as:我看到了将“/usr/mikael/myfile.sql”添加到命令末尾的建议,如下所示:

set command "sqlplus -s user/password@tns /usr/mikael/myfile.sql"

Is that really good?这真的好吗? (I'm working on a prod environment and don't want to mess with it). (我正在开发一个产品环境,不想弄乱它)。

Thanks.谢谢。

set does not do what you think it does. set 不会做你认为它做的事情。 Use利用

command="sqlplus -s user/password@tns @/usr/mikael/myfile.sql"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM