Skip to content
Advertisement

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

I have the following bash script:

#!/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):

/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 :

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.

Advertisement

Answer

set does not do what you think it does. Use

command="sqlplus -s user/password@tns @/usr/mikael/myfile.sql"
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement