NAVIGATION
TABLE OF CONTENTS (Databases):
SEE ALSO:
TCL's link to an Oracle database (could this be the right title?)
I think the question and the answer are missing on this one! :-)
2004/09/07 1:31 pm
Thank you very much. The script worked perfect now. I just added the path of the oratclsh file which is $ORACLE_HOME/bin/oratcl as the following: #!<path of your $ORACLE_HOME>/bin/oratclsh ----> The ! is because it is inside ORacle using oratclsh. Great.!!!!
Re: ...
2004/09/03: Wilfredo Duarte asks:
I have the following script that will be used inside the Oracle OEM console for monitoring the detection of the counting of kind of file in the filesystem. (oratclsh) What I want to detect is if there are files with the extension *.Z in the directory
if {[file exists "/cognos_data/ORADATA/arc/*.Z"] } { puts <oramessage>YES</oramessage> puts <oraresult>-1</oraresult> } else { puts <oramessage>NO</oramessage> puts <oraresult>2</oraresult> }
When in the OS I issue the oratclsh command and then issue the above Solaris script, it gave me the result of NO, when indeed the directory is filled up with files like this:
arch_mapdev0000006291.arc.Z arch_mapdev0000006471.arc.Z arch_mapdev0000006292.arc.Z arch_mapdev0000006472.arc.Z arch_mapdev0000006293.arc.Z arch_mapdev0000006473.arc.Z arch_mapdev0000006294.arc.Z
When I change the script to the following, it gave me the error "child process exited abnormally:"
oratclsh[20]- if {[ls cognos_data/ORADATA/arc/*.Z | wc -l > 1] } { puts <oramessage>YES</oramessage> puts <oraresult>-1</oraresult> } else { puts <oramessage>NO</oramessage> puts <oraresult>2</oraresult> } child process exited abnormally oratclsh[21]-
Also the same result if I change the first line to this:
if {[ls cognos_data/ORADATA/arc/*.Z | wc -l > 1;] } {
I need help with this
Answer (sm)
Your initial attempt was close. The problem is, file exists doesn't do wildcard expansion, so it's looking for a file named *.Z. The command you want to use is glob. glob returns an error if no files match the given pattern, so you'll either need to wrap your glob call in a catch statement, or else pass glob the -nocomplain flag and check for a non-empty list. Here's examples of the two options:
if {[llength [glob -nocomplain "/cognos_data/ORADATA/arc/*.Z"]] > 0 } { puts <oramessage>YES</oramessage> puts <oraresult>-1</oraresult> } else { puts <oramessage>NO</oramessage> puts <oraresult>2</oraresult> }
or,
if {[catch {glob "/cognos_data/ORADATA/arc/*.Z"}] == 0} { puts <oramessage>YES</oramessage> puts <oraresult>-1</oraresult> } else { puts <oramessage>NO</oramessage> puts <oraresult>2</oraresult> }