The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
A simple find and replace without using any regex (bash) srikanths Shell Programming and Scripting 2 03-18-2008 05:08 AM
Simple BASH script? JayC89 Shell Programming and Scripting 16 10-02-2007 04:23 PM
Simple date and time calulation in BASH ripat Tips and Tutorials 0 10-08-2006 03:15 AM
Simple bash for loop problem kingdbag Shell Programming and Scripting 4 09-14-2006 10:00 PM
simple bash script to ftp? satnamx Shell Programming and Scripting 1 04-21-2006 08:18 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-20-2005
Registered User
 

Join Date: Dec 2005
Posts: 3
Simple Bash Script

I'm sure I'm doing something wrong but as I am new to bash shell scripting I'm not sure what:

Here's the code

Quote:
#!/bin/bash

FILEDATE=`date -d yesterday '+%Y%m%d'`
YEARDATE=`date -d yesterday '+%Y'`
LOGFILE="/logs/sitename/$YEARDATE/access$FILEDATE.log"
webalizer -c webalizer.conf $LOGFILE
webalizer.conf is sitting in the same directory as this file which is named webalizer.sh. Can someone tell me if I've got the syntax right -- it that's correct? I'm executing the file as root with sh ./webalizer.sh. webalizer -c file file executes correctly when I manually insert the variable values. The goal is to get this to run through cron.

Thanks!
Reply With Quote
Forum Sponsor
  #2  
Old 12-20-2005
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,644
Quote:
Originally Posted by xaphalanx
I'm sure I'm doing something wrong but as I am new to bash shell scripting I'm not sure what:

Here's the code


webalizer.conf is sitting in the same directory as this file which is named webalizer.sh. Can someone tell me if I've got the syntax right -- it that's correct? I'm executing the file as root with sh ./webalizer.sh. webalizer -c file file executes correctly when I manually insert the variable values. The goal is to get this to run through cron.

Thanks!
Your script assumes webalizer is in the path, it may not be for this script; use the full path. Also that is not the correct way to run a script, in this case it will work becasue you've used bourne syntax, but in general using sh will only work correctly for an sh script, make the script executable and run it directly.

Also since this is a launch script I could consider using "exec" at the start of the last line, once it's launched you only need the webalizer process,not the script.
Reply With Quote
  #3  
Old 12-21-2005
Registered User
 

Join Date: Dec 2005
Posts: 3
Yeah I tried adding the paths and not adding the paths. (/bin/date and /usr/bin/webalizer). I changed the file from .sh to just webalizer and made it rwe for user. Either way I get command not found. command not found. command not found. Any suggestions?
Reply With Quote
  #4  
Old 12-21-2005
Registered User
 

Join Date: Dec 2005
Posts: 3
I added exec to the last line. Now I get... file cannot be opened on the log. So I chmoded it to 0777 and samething. Ughh! Any suggestions would be great! Of course what ever I work out for cronolog and webalizer will be posted....

Tanks
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0