Running Oracle SQL from shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running Oracle SQL from shell script
# 1  
Old 07-18-2011
Running Oracle SQL from shell script

Hi, can anyone help me with this script please. I need the oracle command to go into the unix batch file.
Code:
#!/bin/sh
# A menu driven Shell script which has following options
# for acmtoron@>
#
# 
# Exit
# As per option do the job
#----
 
while :
do
 clear
 echo "   A C M LOG MONITORING (TOR)"
 echo "1. Admin Server Log"
 echo "2. Nohup.out"
 echo "3. System Log"
 echo "4. Alert Log"
 echo "5. Disk Free (kb)"
 echo "6. Disk Free (mounted files)"
 echo "7. Disk Space"    echo "8. Swap Info"
  echo "9. Push Jobs"
 echo "0. Exit"
 echo -n "Please enter option [0 - 9]"
 read opt
 case $opt in 
 1) echo "*********Admin Server (TOR)*********";
    tail -f /opt/bea/SPERogers/SPEDomain/servers/AdminServer/logs/AdminServer.log
 ;;
 2) echo "*********Nohup.out (TOR)*********"
    tail -f /opt/bea/SPERogers/SPEDomain/nohup.out
 ;;
 3) echo "*********System Log (TOR)*********"
    cat /var/adm/syslog/syslog.log
 ;;
 4) echo "*********Alert Log (TOR)*********"
    tail -f /data/oracle10/admin/torosped/bdump/alert_torosped.log
 ;;
 5) echo "*********Disk Free in Kilobytes*********"
    df - b
 ;;
 6)echo "*********Disk Free (mounted files)*********"
    df  -g
 ;;
 7) echo "*********Disk space*********"
    bdf 
 ;;
 8) echo "*********Swap Info*********"
     swapinfo
 ;;
 9) echo "*********Push Jobs*********"
 > su - oracle10
 >sqlplus / as sysdba
 >       SELECT COUNT(DISTINCT DEFERRED_TRAN_ID) "Transactions Queued"   FROM DEFTRANDEST;
  
  
  0) echo "*********Logout*********"
    exit 1;;
 *) echo "$opt is an invalid option. Please select option between 0-8 only";
    echo "Press [enter] key to continue. . .";
     read enterKey;;
  
 esac
done


Last edited by pludi; 07-18-2011 at 05:51 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies

2. Shell Programming and Scripting

Shell script with Oracle PL/SQL

Hi Gurus, I am new to this unix world...I need your help to walk through. I want to learn shell scripting..... The shell script which can be able to use with oracle pl/sql... So please suggest me which shell is good. Which Unix/Linux version is good for this to Install to get practice the... (8 Replies)
Discussion started by: GaneshAnanth
8 Replies

3. UNIX for Advanced & Expert Users

Use of Oracle pl/sql in UNIX shell script

Hi, I have basic knowledge on how to write pl/sql code inside shell script. I am looking for more advance thing. Is there any book for that which can just talk about how to write more advance plsql code inside shell script. Please help Thanks!!!!!! (1 Reply)
Discussion started by: diehard
1 Replies

4. Shell Programming and Scripting

How to run a SQL select query in Oracle database through shell script?

I need to run a SQL select query in Oracle database and have to capture the list of retrieved records in shell script. Also i would like to modify the query for certain condition and need to fetch it again. How can i do this? Is there a way to have a persistent connection to oracle database... (9 Replies)
Discussion started by: vel4ever
9 Replies

5. Shell Programming and Scripting

problem running shell script (for oracle export) in crontab

Hello Gurus, I've been tasked with solving a problem at my new job and I'm stumped. We've got a script that dynamically builds an oracle export parameter files and then runs export from the shell. it runs fine when using the shell, but will NOT run (fails in one spot everytime) when entered... (1 Reply)
Discussion started by: jsheehan223
1 Replies

6. Shell Programming and Scripting

Logging into oracle or SQL from shell script

Hi, I have a shell script where I log on to sqlplus like this log() { sqlplus -s scott/tiger <<! select count(*) from EMP; ! } log Here I have hardcoded/used the username : scott and password : tiger directly to log on to SQLPLUS. If i have my log in information in my profile file... (2 Replies)
Discussion started by: manirsendhil
2 Replies

7. Shell Programming and Scripting

Shell script for accessing a file in the network drive and invoking oracle sql loader

Hi, Please let me know if anybody is having a solution handy for the below tasks... It would be helpful if somebody can resolve my query. I am new to unix and oracle environment and looking for some online reference for completing a task. Task: Check if the network drive exists Check... (0 Replies)
Discussion started by: sayydevara
0 Replies

8. Shell Programming and Scripting

Running SQL Scripts from Shell script - Need insight!

I've a script that fetches various values from the database as below: #! /bin/ksh $conn="user/pwd@service_name" `sqlplus -s << $conn EOF1 @xyz.sql @pqr.sql @abc.sql EOF1` The output of the script should generate txt files containing the results from queries which are further... (6 Replies)
Discussion started by: manthasirisha
6 Replies

9. Shell Programming and Scripting

Running remote shell script containing sql statements

I have a shell script which resides on three SCO machines containing some simple sqlplus statments. I need to run these scripts remotely. Currently, I am trying to use rsh to do so: rsh hostname myscript args The problem is that the arguments to the sqlplus statements in the remote shell... (4 Replies)
Discussion started by: Madbreaks
4 Replies

10. UNIX for Dummies Questions & Answers

how to pass values from oracle sql plus to unix shell script

how to pass values from oracle sql plus to unix shell script (2 Replies)
Discussion started by: trichyselva
2 Replies
Login or Register to Ask a Question