run oracle query remotly with shell script

hello

how to run shell script to excute oracle queries on remote db ?

i have tried as following
sqlplus -s user/password@remote_server "select query;"
but not working
also this one
sqlplus -s user/password@remote_server `select query;`
not working :frowning:
i add this line to run another .sql file like this one :
sqlplus -s user/password@remote_server /oracle.sql
but also not working

thanks to help how to do that and excute the data

regards

sqlplus -s user/password@${ORACLE_SID} 'select query;'

the script should run to excute sql query on remote machine..
solution
sqlplus -s user/password@${ORACLE_SID} 'select query;'
not working ,.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
i added the tns name for the remote machine after $remote_server but not working

Do you have an Oracle client installed on a LOCAL machine?
If so, is tns_names configured correctly? Can you tnsping remote DB by its SID from LOCAL machine?

Hello

thanks for ur support it works like the follwoing
sqlplus -s user/password@remote_server @sql.file

and in the sql.file i add all queries i wants ,,

thanks man for ur support :smiley:

---------- Post updated at 02:23 PM ---------- Previous update was at 02:19 PM ----------

can u help me how to add the output into file so i can load later into mysql db ?

regards