1
var=$(sqlplus -s username/pwd$@SID <<EOF
set heading on
set trimspool off
set linesize 200
set feedback off
SET MARKUP HTML ON
spool output.htmL
SELECT * FROM V$SESSION where username='FSUSER' and PROGRAM='SQL Developer' and OSUSER  NOT IN ('username');
spool off;
exit;
EOF)
echo "$var" > output.txt
exit 0

but the output files shows as ORA error , manual connect is working without any issues from same server .

ERROR: ORA-12162: TNS:net service name is incorrectly specified

SP2-0306: Invalid option. Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM}] [edition=value]] where ::= [/][@<connect_identifier>] ::= [][/][@<connect_identifier>]

Any help here is appreciated

1 Answer 1

2

With a here-document (the construction <<EOF ... EOF) the end-tag should be the only characters on the line. Therefor replace

EOF)

with

EOF
)

Your code has another problem: The $ in V$SESSION is evaluated/parsed, resulting in errors. Parsing can be avoided with a backslash V\$SESSION or by putting quotes around your start-tag EOF:

var=$(sqlplus -S /nolog << 'EOF'
....
EOF
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.