Results 1 to 6 of 6
I think I know what this "should" be doing but it isn't. In fact it is doing the opposite of what I thit it does.
Tell me what you think ...
- 06-26-2008 #1Linux Newbie
- Join Date
- Jun 2006
- Posts
- 139
Help with a script.....
I think I know what this "should" be doing but it isn't. In fact it is doing the opposite of what I thit it does.
Tell me what you think it does:
cd /opt/scripts
isitthere="weddown.log"
if [ -e $isitthere ]
then rm -f weddown.log
else /opt/scripts/weddown.sh > /opt/scripts/weddown.log
fi
thanks
Mace
- 06-26-2008 #2
what it does is obvious i think.
i think you should tell us what you are expecting it to do so that people can tell you where th problem isLinux and me it's a love story
- 06-26-2008 #3Just Joined!
- Join Date
- Feb 2007
- Posts
- 4
what khafa says is true . Are you seeing any discrepancies while executing this script . Let us know.
- 06-26-2008 #4Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
I'm sure you'll want to get down to troubleshooting first, but once you define your variable you can use it across the script to ensure consistency
The script should check from /opt/scripts/ if there is a logfile present...if it is present it removes it and creates a new one.Code:cd /opt/scripts isitthere="weddown.log" if [ -e $isitthere ] then rm -f $isitthere else /opt/scripts/weddown.sh > /opt/scripts/$isitthere fi
Unfortunately everytime this runs it will replace the previous logfile so it isn't testing for anything useful. weddown.sh if successful will create the log and this check if successful will ignore it and create a new one.
Perhaps you want to check if the file is missing and run the script if it hasn't run already?
Also your redirect will overwrite the logfile if it's present. This is probably what you expect anyway but I just thought I'd mention it.Code:cd /opt/scripts isitthere="weddown.log" if [ -z $isitthere ] then /opt/scripts/weddown.sh > /opt/scripts/$isitthere fi
- 06-27-2008 #5Linux Newbie
- Join Date
- Jun 2006
- Posts
- 139
Your right it is very simple..much like the author..

What I am trying to do is have a process run everyother week.
The process creates the weddown.log
SO I think it should go to opt/scripts then check for the log, if the log is there
delete it and finish, if the log is not there then run the next command which when done will create the log.
Now for the wierd part,
I have run this on a test machince and it works flawlessly, but I put it into prod and it will not run right.
Thanks
Mace
- 07-21-2008 #6Linux Newbie
- Join Date
- Jun 2006
- Posts
- 139
btr-
I hate to raise this again but I was looking at something else and when I was looking at 'if' test conditions I saw the -z was for a zero file size.
I want to check to see if the file is present and if it is delete it or if it isn't there fall through and run the script.
Yes I know I'm overwriting the file each time. The file is just a sanity check.
thanks
Mace


Reply With Quote