Visit Our UNIX and Linux User Community


script to update the stats


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to update the stats
# 1  
Old 10-29-2009
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 03:19 PM.. Reason: code tags, please!
# 2  
Old 10-29-2009
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  
Old 10-29-2009
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  
Old 11-02-2009
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  
Old 11-02-2009
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


Previous Thread | Next Thread
Test Your Knowledge in Computers #758
Difficulty: Easy
The Amiga was a family of personal computers introduced by Microsoft in 1985.
True or False?

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute Oracle gather stats via shell script

Hi , I am trying to automate a gather stats in shell script #!/usr/bin/ksh export ORACLE_HOME=/orcl/app/oracle/product/11.2.0.1/db_1 export PATH="$PATH:$ORACLE_HOME/bin" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$ORACLE_HOME/lib32" export TNS_ADMIN=/opt/netprobe/config... (1 Reply)
Discussion started by: neil.k
1 Replies

2. Shell Programming and Scripting

Script to load daily average I/O stats from a .ksh file into Oracle db

Hi can anyone help me with a script to load output of the .ksh file into an Oracle database. I have attached sample output of the information that i need to load to the database (2 Replies)
Discussion started by: LucyYani
2 Replies

3. Shell Programming and Scripting

Newbie to perl - Help with stats script

Hi, this is my first post so here goes..... I need help... I am trying to write a script to produce some stats based on a number of searches in a log file. Now i know how to do this using multiple variables which are really just greps, but I want a more efficent way of doing this as my poor... (1 Reply)
Discussion started by: ARwebble
1 Replies

4. Shell Programming and Scripting

script for taking the stats from a file

i have file which contains data like this every day.i need to pull up a report for counting the 203's in that file for each subscriber id.there are around 200 subscriber id's. all ths Y's which i have written in the script are the subscriber id's.could some one give me an idea as to how do it in... (22 Replies)
Discussion started by: archana234
22 Replies

5. AIX

IO Stats

Aix 5.3 I am trying to view the IO stats. I do the sar 5 5 but that is the WIO and si different than the IO stats right? I am just blanking on this. I know there is a command that I used to run that brings up a whole bunch of live stats that run live such as mem and so on just can't rememeber... (4 Replies)
Discussion started by: rocker40
4 Replies

6. AIX

system stats

I recieved this out put below soemhow. Unfortunatly I did not write down the command I used to get it. Can someone tell me what command I use to gather these stats? OS = AIX 5.3 64Bit System Model: IBM,7026-6H1 Machine Serial Number:... (2 Replies)
Discussion started by: rocker40
2 Replies

7. Shell Programming and Scripting

script to gather weblogic jvm heap size stats

Hello, has anyone written something that will monitor/gather weblogic heap info ? I need to gather size, high/low stats to a file that I can upload to a speadsheet thanks for your help! (2 Replies)
Discussion started by: galenw
2 Replies

8. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies

Featured Tech Videos