Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux HostsFree MagazinesJobs
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Linux Programming & Scripting
Reload this Page Help with a script.....
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Linux Programming & Scripting C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Reply
 
Thread Tools Display Modes
Old 06-26-2008   #1 (permalink)
Linux Newbie
 
Join Date: Jun 2006
Posts: 115
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
mace is offline   Reply With Quote
Old 06-26-2008   #2 (permalink)
Linux Engineer
 
khafa's Avatar
 
Join Date: Apr 2008
Location: Tokyo, Japan
Posts: 769
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 is
__________________
Linux and me it's a love story
khafa is offline   Reply With Quote
Old 06-26-2008   #3 (permalink)
Just Joined!
 
Join Date: Feb 2007
Posts: 4
what khafa says is true . Are you seeing any discrepancies while executing this script . Let us know.
powell is offline   Reply With Quote
Old 06-26-2008   #4 (permalink)
Bigtomrodinator
 
bigtomrodney's Avatar
 
Join Date: Nov 2004
Location: Sunny South-East of Ireland
Posts: 5,183
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
Code:
cd /opt/scripts
isitthere="weddown.log"
if [ -e $isitthere ]
 then rm -f $isitthere
 else /opt/scripts/weddown.sh > /opt/scripts/$isitthere
fi
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.

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?
Code:
cd /opt/scripts
isitthere="weddown.log"
if [ -z $isitthere ]
 then /opt/scripts/weddown.sh > /opt/scripts/$isitthere
fi
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.
__________________
Registered Linux user #378740
New members read here / Forum Rules
#linuxforums on irc.freenode.net
bigtomrodney is online now   Reply With Quote
Old 06-27-2008   #5 (permalink)
Linux Newbie
 
Join Date: Jun 2006
Posts: 115
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
mace is offline   Reply With Quote
Old 07-21-2008   #6 (permalink)
Linux Newbie
 
Join Date: Jun 2006
Posts: 115
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
mace is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
 

Free Magazines
Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe
Systems Management News, the newspaper for IT systems administration and data center managers!
Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe
The Enterprise Newsweekly
eWeek is the essential technology information source for builders of e-business.
subscribe
Oracle Magazine
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe
Total Telecom
Total Telecom is "The Economist of the communications industry".
subscribe
More free magazines »



All times are GMT. The time now is 07:04 PM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.2.0