- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sql command batch file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2009 10:26 PM
тАО10-23-2009 10:26 PM
i have hp-ux 11i v1 with oracle 10g r2 installed i want to create batch file to run sql command monthly i have write this line first in the batch
su - oracle -c sqlplus
the sqlplus is run when i run this batch but its tell me to enter user name and password for sql user what i need is to put this user and password in this batch to run the sql
but i dont know how.
any help please.
regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2009 02:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2009 07:54 AM
тАО10-24-2009 07:54 AM
Re: sql command batch file
Please define 'normal'
- user
- su ?
- SQlplus command.
One way NOT to have to specify a password is when the user is created "IDENTIFIED EXTERNALLY".
Check the Oracle Doc, or help, or:
http://www.orafaq.com/wiki/Oracle_database_Security_FAQ
Is that the method you use to get in 'normally'?
There is really no (good!) reason to switch to the Oracle account to run an oracle task. It's more clear, clean, accountable, to use a proper user or role name.
I suspect the in the case of the batch job the ORA* environment variables were not set up, or set up differently.
Fix that, and perhaps the PATH and be happy?!
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2009 10:44 PM
тАО10-24-2009 10:44 PM
Re: sql command batch file
thanks for help what i need now is to make the .sql file to run my sql command but how i can make this file could you send me example file to see how .
su - oracle -c "sqlplus ane/ane123 @/tmp/ss.sql
i have write this command but the user name feild is appear to put the user name and password for the sql
"Hein" i cant understand what you want to tell me exactly .
thanks for help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2009 12:42 AM
тАО10-25-2009 12:42 AM
Re: sql command batch file
Create a file with your sql statements.
# cat /tmp/ss.sql
select * from tab;
exit
#
Create a file with your sql statements.
As Hein stated above , its is better to use external authentication to accomplish this task.
External Authentication ( Using OS ) for a sql user "ops"
-----------------------------------------------
1) SQL> show parameter os_authent_prefix
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
os_authent_prefix string ops$
2) SQL> alter system set os_authent_prefix='' scope=spfile;
3) create user ops identified externally;
4) grant connect,resource to ops;
5) shutdown and startup the database.
On Unix
-----------
6) useradd -g 106 -d /home/ops -m -k /etc/skel -s /usr/bin/sh ops.
(use dba gid instead of 106 in your case)
7) passwd ops
8) set ORACLE_SID ,PATH,ORACLE_HOME to appropriate values in the ops user .profile.
9)login as ops (unix)
10) schedule sql scripts without giving the oracle username/password.
example :- sqlplus / @myscript.sql ( login as ops (os user)
If you want to execute it from root ,then
su - ops -c "sqlplus / @myscript.sql"
Regards,
Aneesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2009 05:35 AM
тАО10-25-2009 05:35 AM
Re: sql command batch file
What I tried to ask is whether this ever works for you.
When you use is interactively ( normal ), does this command work?
- sqlplus ane/ane123 @/tmp/ss.sql
This relies on ORA_SID to point to the right database.
Maybe that when run as batcg job, or after the "su -" that ORA_SID is a different DB, or not defined at all??
Things to try:
- sqlplus ane/ane123@
and
su - oracle -c "env | grep -i ora"
The other thing I tried to ask was to get you to think about how you normally log in?
Do you normally pass a username and password or not?
And why not run the oracle job under your own account? Why switch user to oracle?
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2009 12:49 AM
тАО10-26-2009 12:49 AM
Re: sql command batch file
sqlplus ane/ane123 @/tmp/ss.sql
this command is working normal without the sid coz i have one sid and its the default sid for one database is not Necessary to provide the sid if you have one database as default. but my main issue is not this section (sqlplus ane/ane123) my issue is the second section (@/tmp/ss.sql) this section is not work.
when i write the complete command like this
su - oracle -c sqlplus ane/ane123 @/tmp/ss.sql the result is he login to the oracle user just that he didnt run the complete command and go to the sql.
i have made new batch this batch contain :
sqlplus ane/ane123
the main batch contain like this:
su - oracle -c ./sqlbatch.sh
this working good and take me to sqlplus command line but he didnt this section:
@/tmp/ss.sql
what i can do for that
any help please
thnks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2009 12:51 AM
тАО10-26-2009 12:51 AM
Re: sql command batch file
don't use sqlplus ane/ane123 but:
sqlplus
conn ane/ane123
....
exit
reason why is that by 'ps -ef|grep [s]qlplus' in teh first way is it possible to cach database password!!
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2009 06:47 AM
тАО10-26-2009 06:47 AM
Re: sql command batch file
To be very secure, you can also change the prefix. Just set a new value for the os_authent_prefix parameter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2009 01:07 AM
тАО11-01-2009 01:07 AM
Re: sql command batch file
your help was usefull but still i have one thing, in my batch file i have this line
spool /u02/dw.sql
but i face this error
"cannot create spool file"
what i can do to resolve this error
thank for help again
best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2009 09:24 PM
тАО11-01-2009 09:24 PM
Re: sql command batch file
Regards,
Aneesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2009 08:29 AM
тАО11-02-2009 08:29 AM
Re: sql command batch file
either this is a permission problem (check the permissions associated with the owner of the sqlplus process) or the file system is full.
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2009 06:21 AM
тАО11-03-2009 06:21 AM
Re: sql command batch file
your help was very usefull thanks again
best regards for you