1829816 Members
1740 Online
109993 Solutions
New Discussion

Scripting woes...

 
SOLVED
Go to solution
Michael Tully
Honored Contributor

Scripting woes...

Hi,

Here is a scripting problem I have. The expert
that I am in script writing (NOT!) gives me this problem and I am swapping out trying to think of the solution. The object of this exercise is to run a command to a logile. If the log file is empty continue to run the next command, if not exit and run the next chain, or have I got the whole thing wrong and should go back to school?


omnimm -list_scratch_media $POOL1 > $POOL_LOG
if (log file is empty, what is the syntax I use)
then
omnimm -move_medium $tape1 $POOL1
else
echo "Scratch Tape already available in $POOL1"
fi

TIA
-Michael
Anyone for a Mutiny ?
12 REPLIES 12
James R. Ferguson
Acclaimed Contributor
Solution

Re: Scripting woes...

Hi Michael:

How about;

# if (( `wc -c < $POOL_LOG` == 0 ))
> then
> echo "empty file!"
> fi

Regards!

...JRF...
harry d brown jr
Honored Contributor

Re: Scripting woes...

-s file True, if file exists and has size greater than zero.

live free or die
harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: Scripting woes...

-e file True, if file exists.

if [[ -s logfile ]]


live free or die
harry

http://www.physik.uni-freiburg.de/cip/man.cgi?1 ksh
Live Free or Die
Deepak Extross
Honored Contributor

Re: Scripting woes...

How about

if [! -s ${POOL_LOG} ]
# the size of the logfile is zero

See man test for details
Kevin Wright
Honored Contributor

Re: Scripting woes...

to test..
if [[ ! -s $Logfile ]];then
echo "empty file"
fi
Michael Tully
Honored Contributor

Re: Scripting woes...

Thanks Guys,

I think I have enough to stop swapping out. I probably need to add some more RAM or increase Buffer Cache!

Points to awarded as soon as test is complete!
Thanks again!

-Michael
(Never be afraid to ask, nobody knows everything!)
Anyone for a Mutiny ?
harry d brown jr
Honored Contributor

Re: Scripting woes...

I'd suggest a reboot, but I'm sure we are talking unix here and not some micosoftie os :-))

Maybe a "user < cold_beer" would do?

live free or die
harry
Live Free or Die
Michael Tully
Honored Contributor

Re: Scripting woes...

Thanks again, Deepak yours had a space omitted.... hence only a '9' from the judges.....

Harry, how about this...
if [ ! -s ${FRIDGE} ]
then /usr/local/bin/different_fridge
else
echo "Dear I'm off to the pub!"
fi

and BTW was the school that I needed to attend
have a pre-requisite of knowing how to read
German?? :^))

-Michael
Anyone for a Mutiny ?
harry d brown jr
Honored Contributor

Re: Scripting woes...

Nein, but they just happened to be the first in my search list.
Live Free or Die
harry d brown jr
Honored Contributor

Re: Scripting woes...

I forgot to add that I like the script, especially the _fridge extension to the language.

live free or die
harry
Live Free or Die
Deepak Extross
Honored Contributor

Re: Scripting woes...

missing space? oh well...maybe i need some of that cold_beer too!
Deepak Extross
Honored Contributor

Re: Scripting woes...

missing space, eh? oh well...maybe i could do with some of that cold_beer too!