简体   繁体   中英

sqlplus fails on execution from shell script, but works fine from it's execution from terminal

I have a software that runs a shell script. There is a sqlplus command among with a lot of other staff in that shell script.

sqlplus -L 'user/passwd'@\'localhost:1521/orcl\' @file_path.ddl test_cpm_user test_cpm_password CPMDAT CPMIDX

Shell scripts fails on that line above with message:

SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 12 11:50:36 2018

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified


SP2-0751: Unable to connect to Oracle.  Exiting SQL*Plus

However, if I run it by myself from terminal it works fine. What might be a reason of such behaviour?

Try below command with braces since I see hostname contains special characters

sqlplus -L '{user}/{passwd}'@{hostname}' @file_path.ddl test_cpm_user test_cpm_password CPMDAT CPMIDX

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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