The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 08:08 AM
Simple BASH script? JayC89 Shell Programming and Scripting 16 10-02-2007 07:23 PM
Simple date and time calulation in BASH ripat Tips and Tutorials 0 10-08-2006 06:15 AM
Simple bash for loop problem kingdbag Shell Programming and Scripting 4 09-15-2006 01:00 AM
simple bash script to ftp? satnamx Shell Programming and Scripting 1 04-21-2006 11:18 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-20-2005
xaphalanx xaphalanx is offline
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!
  #2 (permalink)  
Old 12-20-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
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.
  #3 (permalink)  
Old 12-21-2005
xaphalanx xaphalanx is offline
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?
  #4 (permalink)  
Old 12-21-2005
xaphalanx xaphalanx is offline
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:24 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0