The UNIX and Linux Forums

The UNIX and Linux Forums (http://www.unix.com/index.php)
-   Shell Programming and Scripting (http://www.unix.com/shell-programming-and-scripting/)
-   -   Simple Bash Script (http://www.unix.com/shell-programming-and-scripting/23950-simple-bash-script.html)

xaphalanx 12-20-2005 05:48 PM

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!

reborg 12-20-2005 08:13 PM

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.

xaphalanx 12-21-2005 02:28 PM

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?

xaphalanx 12-21-2005 02:54 PM

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


All times are GMT -4. The time now is 07:50 PM.

Linux and Unix Supported by: vBulletin
Search Engine Optimisation provided by DragonByte SEO v1.1.4 (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
The UNIX and Linux Forums Content Copyright ©1993-2013. All Rights Reserved.
Forum Operations by The UNIX and Linux Forums