Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



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

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-29-2009
Registered User
 

Join Date: Dec 2008
Location: coimbatore
Posts: 111
script to update the stats

Hi,

I am using the below shell script to update the webalizer stats:


Code:
#!/bin/bash

username='elogic1'
domain='abcd.com'
path_to_webalizer='/hsphere/shared/bin/webalizer'
path_to_logs='/hsphere/local/home/elogic1/logs/abcd.com'
output_dir_statistics='/hsphere/local/home/elogic1/abcd.com/webalizer'

log_file=`ls $path_to_logs/$domain*|grep -v .gz`

cat $log_file|$path_to_webalizer -n $domain -o $output_dir_statistics

The above scripts updates the stats for one domain at a time.Let assume, if there are n-number domains under the user "elogic1", how can I effectively use this script to update for all the domains under the user.

Last edited by vgersh99; 10-29-2009 at 02:19 PM.. Reason: code tags, please!
Sponsored Links
  #2 (permalink)  
Old 10-29-2009
Registered User
 

Join Date: Jul 2009
Location: Gresham, OR
Posts: 157
How about...


Code:
#!/bin/bash

username='elogic1'
domains='abcd.com efgh.com ijkl.com'
path_to_webalizer='/hsphere/shared/bin/webalizer'
path_to_logs='/hsphere/local/home/elogic1/logs/abcd.com'
output_dir_statistics='/hsphere/local/home/elogic1/abcd.com/webalizer'

for domain in $domains
do
  log_file=`ls $path_to_logs/$domain*|grep -v .gz`
  cat $log_file|$path_to_webalizer -n $domain -o $output_dir_statistics
done

  #3 (permalink)  
Old 10-29-2009
Registered User
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,320
I think you need to stuff a little bit more into the loop, like e.g.:


Code:
#!/bin/bash

username=elogic1
domains="abcd.com efgh.com ijkl.com"
path_to_webalizer=/hsphere/shared/bin/webalizer

for domain in $domains
do
  path_to_logs=/hsphere/local/home/elogic1/logs/$domain
  output_dir_statistics=$path_to_logs/webalizer
  log_file=$(ls $path_to_logs/$domain*|grep -v .gz)
  $path_to_webalizer -n $domain -o $output_dir_statistics $log_file
done

  #4 (permalink)  
Old 11-02-2009
Registered User
 

Join Date: Dec 2008
Location: coimbatore
Posts: 111
How, about the below, will this be work:

#!/bin/bash

username=elogic1
domains="/home/elogic1/*"
path_to_webalizer=/hsphere/shared/bin/webalizer

for domain in $domains
do
path_to_logs=/hsphere/local/home/elogic1/logs/$domain
output_dir_statistics=$path_to_logs/webalizer
log_file=$(ls $path_to_logs/$domain*|grep -v .gz)
$path_to_webalizer -n $domain -o $output_dir_statistics $log_file
done
  #5 (permalink)  
Old 11-02-2009
Registered User
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,320
Almost. Assuming that /home/elogic1 contains only the names of the domains, you need to cut off the path of the $domain variable:

Code:
#!/bin/bash

username=elogic1
domains="/home/elogic1/*"
path_to_webalizer=/hsphere/shared/bin/webalizer

for domain in $domains
do
  path_to_logs=/hsphere/local/home/elogic1/logs/${domain##*/}
  output_dir_statistics=$path_to_logs/webalizer
  log_file=$(ls $path_to_logs/$domain*|grep -v .gz)
  $path_to_webalizer -n $domain -o $output_dir_statistics $log_file
done

Sponsored Links
Reply

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Newbie to perl - Help with stats script ARwebble Shell Programming and Scripting 1 03-25-2009 04:52 PM
script for taking the stats from a file archana234 Shell Programming and Scripting 22 03-19-2009 08:36 PM
Google Sitemap Update Frequency and Sitemap Stats Linux Bot Complex Event Processing RSS News 0 02-02-2009 09:50 PM
script to gather weblogic jvm heap size stats galenw Shell Programming and Scripting 2 02-07-2008 01:34 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 04:06 AM



All times are GMT -4. The time now is 05:19 PM.


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

Content Relevant URLs by vBSEO 3.2.0