alias to a shell script - tablespace size


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting alias to a shell script - tablespace size
# 8  
Old 01-13-2011
It's staring me in the face.
This time it is the alias!

You are unwittingly creating variables in your environment from the first run which are available to the second run.

Quote:
ts_size='. ~/util/sql/ts_size.sh'
The problem is the "dot-space" in the alias. This causes the script to be executed in the current environment rather than in a clean Shell. It is a useful feature of Shell ... but you don't want to use it here.

Try:
Code:
ts_size='~/util/sql/ts_size.sh'

This User Gave Thanks to methyl For This Post:
# 9  
Old 01-13-2011
Hi Methyl,

Sorry, I did not see your post...here is the code as it stands now. I played around with the ` and {} surrounding the variables. But no luck.
As you can see, I have removed the ` and it still behave incorrectly.
My logic for calculating wild is correct as you mention. I am testing if the input has a wild character which in this case is "%". So a non zero value confirms it. Based on that I set = or like.
However, once I use the wild character, it seems to remember it for the next run.

and the alias is defined as:
Code:
> alias|grep -i ts_size
ts_size='. ~/util/sql/.ts_size.sh'


Code:
#!/bin/ksh
#xwhere=" "
#xwild=" "
#wild=" "
if [ $# -eq 1 ]
then
wild=$(echo $1 | awk '{print index($1,"%") }')
# echo $wild
if [ $wild -ne 0 ]
then
xwild="like"
else
xwild="="
fi 
xwhere="where tablespace_name "$xwild" upper('"$1"')"
fi
echo $xwhere
sqlplus -s / <<eof 2>/dev/null
set linesize 120;
set pagesize 1000;
set feedback off;
set echo off;
set heading off;
col tablespace_name forma a30;
select round(sum(bytes/1024/1024/1024),2) as "Gb",' Gb ', tablespace_name from dba_data_files $xwhere group by rollup (tablespace_name) order by 1 asc;
eof

---------- Post updated at 07:16 PM ---------- Previous update was at 07:04 PM ----------

Hi Methyl,

Is there a way to give you multiple thanks...that's it. The alias was the culprit in the end, plus the earlier fixes with spaces etc..

My hats off to you.

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script for getting the file size

Hi can some one please help me how i can get the output i require: My text file "sample.txt" contains the text like below Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_fedora-lv_root 15G 2.6G 12G 19% /hari Filesystem Size ... (3 Replies)
Discussion started by: harimhkr
3 Replies

2. Shell Programming and Scripting

Script to check Oracle tablespace

I'm new to unix script, and I need to check the tablespaces daily, here is the script(quite simple), but it does not work. Did I missed something ? Please guide me, Many thanks ! #!/bin/sh echo "ORA TABLEASPACE:" sqlplus system/oracle as sysdba; set pagesize 9999; set linesize 132; ... (5 Replies)
Discussion started by: dehetoxic
5 Replies

3. Shell Programming and Scripting

tablespace monitoring script

I have prepared the below script to monitor the tablespace and alert the users whenever it reaches a threshold limit. #!/bin/sh . /home/.profile sqlplus -s $LOGON << .eof > $scripts/check_tablespace.temp set pages 0 select tablespace_name, free_percent from ( SELECT... (4 Replies)
Discussion started by: svajhala
4 Replies

4. Shell Programming and Scripting

Global alias does not work in shell script

Hi Linux Set up - alias ls='ls -l' Then run script #! /bin/ksh sub() { ls } sub Is there any way to get it working. I don't want to define alias inside of the program Thank you (2 Replies)
Discussion started by: zam
2 Replies

5. Shell Programming and Scripting

error in script path for tablespace usage

Hi , I am trying to run this script in crontab but I get errors. When I run it explicitly like ./monitor_tblsp from another location then it runs fine . I am messing somewhere with paths but I don't know where and how . Please help . Here is the error part ./monitor_tblsp: touch: not... (2 Replies)
Discussion started by: capri_drm
2 Replies

6. Shell Programming and Scripting

Need help in a shell script to edit a tablespace creation script.

Hi, CREATE TABLESPACE aps_blob_large01 DATAFILE '/c2r6u13/u03/oradata/qnoldv01/aps_blob_large0101.dbf' SIZE X 270532608 REUSE DEFAULT STORAGE (INITIAL 134217728 NEXT... (2 Replies)
Discussion started by: rparavastu
2 Replies

7. Shell Programming and Scripting

Shell Script to find the tablespace size in oracle.

Hi, I need to execute a script to find the tablespace size in oracle.But i get an error.:confused: Script Executed:- #!/bin/ksh ORACLE_SID= oracelinstance ORACLE_HOME= oracle path PATH=$ORACLE_HOME/bin export ORACLE_SID ORACLE_HOME PATH sqlplus... (4 Replies)
Discussion started by: vighna
4 Replies

8. Shell Programming and Scripting

Size of an array in sh shell script

Is there a way to find out the size of an array in sh shell script? Thanks. (1 Reply)
Discussion started by: trivektor
1 Replies

9. Shell Programming and Scripting

Bourne: How to invoke an alias from within a shell script

Bourne: How to invoke an alias from within a shell script If I type in the alias in the command line, it runs If I insert that same alias into my shell script and run the shell script, the alias is not invoked. Help please. (2 Replies)
Discussion started by: techshots
2 Replies

10. Shell Programming and Scripting

Get file size in c shell script?

Hi, I want to use an 'if statement' that will check if a certian file is greater in size than a certain value given by the user, but cannot get it to work. Do you have any ideas how this can be done? Your help is appreciated! (6 Replies)
Discussion started by: Dado
6 Replies
Login or Register to Ask a Question