Hi,
I have a bourne shell script that needs to login into sqlplus and execute a stored procedure. I need this shell script to be run under a user crontab.
It works fine if run under normal shell prompt.
But it gave error message in my log file when run under crontab:
SQL*Plus: Release 10.1.0.5.0 - Production on Fri Jun 10 18:51:00 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name: SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
where <logon> ::= <username>[/<password>][@<connect_identifier>] | /
Enter user-name: Enter password:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
Execution Completed
This is the shell script:
PATH=$PATH; export PATH;
ORACLE_HOME=/orabin/10.1.2;
export ORACLE_HOME;
/orabin/10.1.2/bin/sqlplus oper/MyPassword <<EOF
execute MY_STORED_PGM_PKG.CREATE_PGM;
exit;
/
EOF
echo "Execution Completed "
I need to bring in the login env variables (like in .profile).
I am using SunOS 5.10 = Solaris 10.
Thanks.