From owner-freebsd-questions@FreeBSD.ORG Tue May 27 06:19:53 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 779B937B401 for ; Tue, 27 May 2003 06:19:53 -0700 (PDT) Received: from juice.thebigchoice.com (pc1-nott2-3-cust18.nott.cable.ntl.com [80.4.204.18]) by mx1.FreeBSD.org (Postfix) with SMTP id 223CE43FBD for ; Tue, 27 May 2003 06:19:52 -0700 (PDT) (envelope-from matt@thebigchoice.com) Received: (qmail 54224 invoked from network); 27 May 2003 13:19:54 -0000 Received: from localhost.proweb.net (HELO thebigchoice.com) (127.0.0.1) by juice.thebigchoice.com with SMTP; 27 May 2003 13:19:54 -0000 Message-ID: <3ED365FA.5080900@thebigchoice.com> Date: Tue, 27 May 2003 14:19:54 +0100 From: Matt Heath User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.3) Gecko/20030425 X-Accept-Language: en, en-us MIME-Version: 1.0 To: "Dave [Nexus]" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-questions@freebsd.org Subject: Re: shell/awk scripting help - parsing directories to gainuser/file information for commands X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 May 2003 13:19:53 -0000 ls /www/*/logs/*.access_log | awk -f webalize-it.awk where the file webalize-it.awk contains BEGIN { FS = "/" } { user = $3 domain = $5 # extract the domain name gsub("^" user, "", domain) gsub("\.access_log$", "", domain) cmd = sprintf("webalizer -n %s -o /www/%s/stats/", domain, user) system(cmd) } >have a number of uses for this where I am trying to get away from maintaining >lengthy static files which contain all the statically entered commands to run >for a cron job... > >for example; > >- need to run webalizer of a number of user websites and directories >- can run webalizer without a customized conf file, but need to provide >hostname, outputdir and other such variables from the command line >- can list all the log files which give the appropriate information > ># ls /www/*/logs/*.access_log > >generates... > >/www/user1/.logs/user1domain1.com.access_log >/www/user1/.logs/user1domain2.com.access_log >/www/user2/.logs/user2domain1.com.access_log >/www/user2/.logs/user2domain2.com.access_log >/www/user3/.logs/user3domain1.com.access_log >/www/user3/.logs/user3domain2.com.access_log > >what I am trying to script is something that does; > > >for i in /www/*/logs/*.access_log; > ereg (user)(domain_name) from $i; > do webalizer -n $domain_name -o /www/$user/stats/; >done > > >...as this would eliminate human error in maintaining a file which contains the >appropriate lines to handle this via cron or something every night. > >This is one example, there are a slew of other similar applications that I would >use this for. have played with awk as well, just can't wrap my head around this >(not a shell scripting person by trade). > >Any guidance or insight would be appreciated. > >Dave > > >_______________________________________________ >freebsd-questions@freebsd.org mailing list >http://lists.freebsd.org/mailman/listinfo/freebsd-questions >To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > > > >