Getting error while getting status of active and inactive sessions from ORACLE DB


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting error while getting status of active and inactive sessions from ORACLE DB
# 1  
Old 09-26-2010
Question Getting error while getting status of active and inactive sessions from ORACLE DB

Hi All,
I have a written a test script which retrieves the status of active and inactive sessions from oracle DB, but i am receiving error while executing.
My script is
Code:
filepath="/home/ocsg/scripts/db_session_report/current_session_report.txt"
INACTIVE_SESSIONS=`/home/ocsg/client10g/bin/sqlplus -s abc/abc@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.0.1)(PORT=1521)))(CONNECT_DATA=(SID=test)))' << EOFSQL
set head off
select count(*) from V$SESSION;
exit;
EOFSQL`
echo $INACTIVE_SESSIONS > $filepath
echo DB SESSION REPORT : $INACTIVE_SESSIONS

and error i receive when executing the above script is as follows:
Code:
db_session_alert ERROR at line 1: ORA-04044: procedure, function, package, or type is not allowed here

Please help me where i am wrong in the above script.
# 2  
Old 09-27-2010
Quote:
Originally Posted by poweroflinux
...
My script is
Code:
filepath="/home/ocsg/scripts/db_session_report/current_session_report.txt"
INACTIVE_SESSIONS=`/home/ocsg/client10g/bin/sqlplus -s abc/abc@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.0.1)(PORT=1521)))(CONNECT_DATA=(SID=test)))' << EOFSQL
set head off
select count(*) from V$SESSION;
exit;
EOFSQL`
echo $INACTIVE_SESSIONS > $filepath
echo DB SESSION REPORT : $INACTIVE_SESSIONS

and error i receive when executing the above script is as follows:
Code:
db_session_alert ERROR at line 1: ORA-04044: procedure, function, package, or type is not allowed here

Please help me where i am wrong in the above script.
The shell mangles your SQL commands due the special meaning of characters like "$" and "*".

Use this form to fetch the count from v$session -

Code:
$ 
$ 
$ cat -n oratest.sh
     1    COUNT=$(printf "set pages 0\nselect count(*)||'' from v\$session;" | sqlplus -s test/test)
     2    echo "COUNT = $COUNT"
$ 
$ 
$ ./oratest.sh
COUNT = 23
$ 
$ 
$ 

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find number of ACTIVE SSH putty sessions, excluding where the user hopped on to a diff server

Hi - If iam logged on to server A, on 4 putty windows using SSH ... and out of these 4 logged-in sessions, in one of the sessions if i did SSH from server A to server B; i would now have 4 putty windows sessions ... of which 3 are actively logged on to Server A while 1 putty window is actively... (2 Replies)
Discussion started by: i4ismail
2 Replies

2. UNIX for Dummies Questions & Answers

Error of Snapshot origin volumes can be resized only while inactive

Hello, I am trying to increase lvsize however it gives below error what's the way that I can increase this size? # lvextend -L +20G /dev/VGExaDb/volsnap Snapshot origin volumes can be resized only while inactive: try lvchange -an Best regards, Vishal (1 Reply)
Discussion started by: admin_db
1 Replies

3. UNIX for Advanced & Expert Users

Help in Oracle Inactive Sessions

hi , i could see 50-60 oracle inactive session running under my application name, does this cause any issue.. or can this inactive session be excluded , if so how can we reduce them or exclude them , your inputs are much required. my application runs on C++ with oracle , pro*c involved.... (1 Reply)
Discussion started by: senkerth
1 Replies

4. UNIX for Dummies Questions & Answers

Active sessions open or long time

What kind of problems can be faced if any session which connects to unix server is open for longer time? How to find out from how much time that session is idle? :) (2 Replies)
Discussion started by: anandgodse
2 Replies

5. Shell Programming and Scripting

Killing oracle sessions

Hi, I need to write a shell script to kill all oracle sessions. I have to login in unix with unix userid and have to use sudo command to login with oracle userid and has to find out all oracle related sessions that are running currently and has to kill all sessions. please suggest me the way... (1 Reply)
Discussion started by: rohan10k
1 Replies

6. Shell Programming and Scripting

Removing Inactive Sessions

Hi, I have the following script: # Inactive Users Removed # # Created by: stuaz # Created on: 16/03/11 # # This script runs from the Cron #################################### # Variables email=blah@blah.com log=/utils/sdennis/inactiveusers.log # # Command to find inactive... (3 Replies)
Discussion started by: stuaz
3 Replies

7. Red Hat

Installing RedHat 8.0 onto Dell PowerEdge SC1425 - hdc: status error: status = 0x58

I have successfully installed RedHat 8.0 onto a Dell PowerEdge SC1425 today. This server has two SATA hard drives, and an IDE DVD-ROM drive. Using the following kernel parameters, i successfully installed across both hard drives from CD: ide0=0x1f0,0x3f6,14 vga=791 resolution=1024x768 expert... (5 Replies)
Discussion started by: fishsponge
5 Replies
Login or Register to Ask a Question