Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 30th August 2006, 12:13
dips dips is offline
Junior Member
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default need urgent help for writing shell script

Hello All ,

I am learning Shell Script and i am very fresher . I need help to write one shell script .

We are generating several logs files in our testsuite system . I need to generate fails as per the host ,version and productwise .

The data is stored in different directories and run.log contains fails records with ! sign . I am extracting fails from each directory but cant't accumalte as per the product wise . because product name is stored in Master file product.dat.

The product.dat is Master file contains 2 column
Test Name ProductName
/dialy/test SiCat
/daily/yyyy YRS
/daily/ttttt SiCat
/daily/rttttt SiCat
/daily/wwww PSD
/daily/uuuu YRS



The second file which is generated only contain fails test name for whole system .
The data format is like this
/users/test/krachel/9/run.log
! /daily/wwww
! /daily/test1
! /daily/rrrrr
/users/test/limo/10/run.log
! /daily/wwww
! /daily/test1

The host and version i want to extract form line /users/test/

I have store data like this
Host Version SiCat YRS PSD
limo 10 3 3 5
krache 9 5 7 0
Reply With Quote
Sponsored Links
  #2  
Old 30th August 2006, 12:35
Ben Ben is offline
Moderator
 
Join Date: Jul 2006
Posts: 1,029
Thanks: 7
Thanked 62 Times in 56 Posts
Default

Due to the fact of not knowing shell scripting quite good, why do you want to do that with a shell script instead of using sth. like perl, python, php, scripting languages that exists on most *nix installations, that make tasks like this more easy.
Reply With Quote
  #3  
Old 30th August 2006, 13:11
dips dips is offline
Junior Member
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

please give me soultions in Perl . I will be thankful to you .
Reply With Quote
  #4  
Old 31st August 2006, 10:54
dips dips is offline
Junior Member
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hope i will get help from unix & perl experts . I am waiting fr reply .
Thanks in advance
Reply With Quote
  #5  
Old 31st August 2006, 11:07
Ben Ben is offline
Moderator
 
Join Date: Jul 2006
Posts: 1,029
Thanks: 7
Thanked 62 Times in 56 Posts
Default

A solution is no help.
But you can find all the things you need in perl here: http://perldoc.perl.org/perl.html

Here you can find things about opening files (http://perldoc.perl.org/functions/open.html), how to cycle to its contents.
Split (http://perldoc.perl.org/functions/split.html), subtring (http://perldoc.perl.org/functions/substr.html) will be helpfull for stringmanipulation, in that case.

It is also helpfull to take a look at perldata (http://perldoc.perl.org/perldata.html) for datatypes you could use storing and cumulating your data read from the files.

hth
Reply With Quote
  #6  
Old 31st August 2006, 13:52
dips dips is offline
Junior Member
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

when i will start reading and complite the program . Thanks anyway for no help .
Reply With Quote
  #7  
Old 31st August 2006, 23:11
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

Quote:
Originally Posted by dips
Hello All ,

I am learning Shell Script and i am very fresher . I need help to write one shell script .
This is an essential read if you want to do shell scripting: http://www.tldp.org/LDP/abs/html/index.html
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #8  
Old 2nd September 2006, 12:54
Ben Ben is offline
Moderator
 
Join Date: Jul 2006
Posts: 1,029
Thanks: 7
Thanked 62 Times in 56 Posts
Default

Quote:
Originally Posted by dips
Thanks anyway for no help .
Reply With Quote
  #9  
Old 3rd September 2006, 19:40
drks drks is offline
Junior Member
 
Join Date: Aug 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

Quote:
The host and version i want to extract form line /users/test/

I have store data like this
Host Version SiCat YRS PSD
limo 10 3 3 5
krache 9 5 7 0

Um, I'm not sure exactly what you need, but if you are just wanting to extract fields from a file that is easy. For example, if the file is '/users/test/file' and the contents are what you listed above then you would grab the HOST (column 1) and VERSION (column 2) this way:

Code:
wdierkes$ cat /users/test/file | awk {' print "HOST: "$1 "  VERSION:  "$2 '}
HOST: limo  VERSION:  10
HOST: krache  VERSION:  9

That is just a very simple example. Please feel free to clarify if that doesn't answer your question.
__________________
drks - http://www.5dollarwhitebox.org
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help for writing shell script chris_87 Programming/Scripts 7 4th April 2007 15:50
shell script problem (urgent) selvam Programming/Scripts 2 27th July 2006 17:47
Shell Script Need Help mphayesuk Programming/Scripts 4 27th June 2006 12:06
shell script Nnyan Programming/Scripts 4 24th June 2006 13:47
Shell script is broken... Duplex Installation/Configuration 4 16th January 2006 09:55


All times are GMT +2. The time now is 02:44.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.