parsing script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parsing script
# 1  
Old 04-29-2011
parsing script

Hello everybody!
I'm trying to create a parse script but I keep getting errors. Can you please help me out.

Code:
#!/bin/bash
#Blank Blank
#April 6, 2011
##########################################################################################
#Script from Google.com
#Modified by blank blank
#Modified on April 6, 2011
##########################################################################################
#This Script is to file parse the log files while implementing a timing script
##########################################################################################
##########################################################################################
#set -x #Uncomment to debug this script
#set -n #Uncomment to check script syntax without any execution,
##########################################################################################
##########################################################################################
#
#From Randy K. Micheal
#
function hello
{
echo "source?"
read A
echo "destination?"
read B
INFILE= $A #/home/blank/Desktop/script/access_log* 
OUTFILE= $B #writefile.out

}

########################################################################################

function rotate
{
while [[ cat_while_read_LINE ]];     # Loop forever...until this function is killed
do
    (( RCOUNT = RCOUNT + 1 )) # Increment the RCOUNT

    case $RCOUNT in
    1) echo "."
       sleep 1s
       ;;
    2) echo ".."
       sleep 1s
       ;;
    3) echo "..."
       sleep 1s
       ;;
    4) echo "...c"
       sleep 1s
       ;;
    5) echo "...co"
       sleep 1s
       ;;
    6) echo "...cof"
       sleep 1s
       ;;
    7) echo "...coff"
       sleep 1s
       ;;
    8) echo "...coffe"
       sleep 1s
       ;;
    9) echo "...coffee"
       sleep 1s
       ;;
    10) echo "...coffeeB"
       sleep 1s
       ;;
    11) echo "...coffeeBr"
       sleep 1s
       ;;
    12) echo "...coffeeBre"
       sleep 1s
       ;;
    13) echo "...coffeeBrea"
       sleep 1s
       ;;
    14) echo "...coffeeBreak"
       sleep 1s
       ;;
    15) echo "...coffeeBreak."
       sleep 1s
       ;;
    16) echo "...coffeeBreak.."
       sleep 1s
       ;;
    17) echo "...coffeeBreak..."
       sleep 1s
       ;;
    *) RCOUNT="0" # Reset the RCOUNT to "0", zero.
       ;;
    esac
done
}

########################################################################################
#
#From Randy K. Micheal
#
function cat_while_read_LINE
{
#Method 1

#Zero out the $OUTFILE

>$OUTFILE

cat $INFILE | while read LINE
do
    echo "$LINE" >> $OUTFILE
    :
done
}

########################################################################################
#
# From Randy K. Micheal
#
#
#QFILE=access_log.*
#{
#cat $QFILE | while read LINE
#do
#    echo "$LINE" >> $OUTFILE
#    :
#done
#}

########################################################################################

#Time and parse the file
hello
echo "parsing"
rotate 
ROTATE_PID=$!
X=$(date +%s)
cat_while_read_LINE &
Y=$(date +%s)
kill $ROTATE_PID
DIF=$(( $Y - $X ))
MIN=$(( $DIF / 60 ))
SEC=$(( $DIF % 60 ))
if [ $DIF -ge 60 ]
then
    echo "The file(s) were parsed in $MIN minute(s) and $SEC seconds!\n";
else
    echo "The file(s) were parsed in $DIF second(s)! \n";
fi




These are the errors that I keep on getting

/home/blank/Desktop/script/access_log-20101201: line 870: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 871: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 872: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 873: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 874: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 875: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 876: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 877: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 878: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 879: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 880: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 881: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 882: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 883: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 884: 209.221.168.11: command not found
/home/blank/Desktop/script/access_log-20101201: line 885: 66.249.65.70: command not found
/home/blank/Desktop/script/access_log-20101201: line 886: 123.125.66.124: command not found
/home/blank/Desktop/script/access_log-20101201: line 887: 207.46.13.86: command not found
/home/blank/Desktop/script/access_log-20101201: line 888: 220.181.7.130: command not found
/home/blank/Desktop/script/access_log-20101201: line 889: 129.121.131.74: command not found
/home/blank/Desktop/script/access_log-20101201: line 890: 129.121.131.74: command not found
/home/blank/Desktop/script/access_log-20101201: line 891: 208.115.111.248: command not found
/home/blank/Desktop/script/access_log-20101201: line 892: 208.115.111.248: command not found


Moderator's Comments:
Mod Comment Please use code tags when posting code.

Last edited by Perderabo; 04-30-2011 at 05:02 PM.. Reason: add code tags
# 2  
Old 04-30-2011
I guess that the problem is due to the [[ ]] in the rotate function.
You need cat_while_read_LINE to return true (0) for the while loop to continue and false (non 0) for the while loop to terminate. No square brackets are needed.
# 3  
Old 04-30-2011
Can you show me an example of how to implement this return true(0)

---------- Post updated at 09:17 AM ---------- Previous update was at 09:15 AM ----------

Can you show me an example of how to implement the return true(0)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script and parsing

Hello I am trying to find how to do the following with awk and other tools. Find a line in the file where the element 1 is equal to 12345, from the first occurrence, in that line find the element 11 what is equal to and print all lines in file where their element 11 is equal to the value of... (2 Replies)
Discussion started by: koutroul
2 Replies

2. Shell Programming and Scripting

Parsing ksh script

Is there any tool that can parsing ksh script into grammar format? e.g. the tool can parse the following ksh script: echo "hello"> abc.txt cp /home/user/abc/.profile /home/user/abc/myprofile into GENERATE abc.txt COPY /home/user/abc/.profile TO /home/user/abc/myprofile My server OS... (2 Replies)
Discussion started by: cstsang
2 Replies

3. Shell Programming and Scripting

Parsing a $VARIABLE within a script.

Hello all, I have a situation where I need to parse for certain items from a $VARIABLE within a sh script. The sh script is run when an alert comes in. The alert data payload has a Message field called "EVENTMSG" The script that is run takes the "EVENTMSG" and prints it out to the... (12 Replies)
Discussion started by: dlundwall
12 Replies

4. Shell Programming and Scripting

parsing using shell script

I have a file parameters.txt which contains 151524 151525 I have another file OID.csv which contains NE Version Object Type ID SDK param name Object OID test1 Start: 4.2 End: 4.2 pan 151524 speed ... (5 Replies)
Discussion started by: LavanyaP
5 Replies

5. Shell Programming and Scripting

Need of a Parsing Script Assist...

Im trying to find a script that will pull ip addresses along with the date and time sort it by ip addresses and output it to a file... As a newbie to scripting im kinda stumped here...and suggestions? (2 Replies)
Discussion started by: jspinal
2 Replies

6. Shell Programming and Scripting

Log parsing script

Hello, I have a script that parses logs and sends the output via digitally signed and encrypted email. This script uses grep -v to exclude patterns in a file. The problem I have is if this is run via cron none of the pattern matching seems to occur. If I run it by hand it runs exactly as it is... (2 Replies)
Discussion started by: wpfontenot
2 Replies

7. Shell Programming and Scripting

XML file parsing using script

Hi I need some help with XML file parsing. I have an XML file with the below tag, I need a script to identify the value of srvcName which is this case is "AAA srvc name". I need to put contents of this value which is AAA srvc and name into different variables using an array and then reformat it... (6 Replies)
Discussion started by: zmfcat1
6 Replies

8. Shell Programming and Scripting

Perl script parsing Help

Hi All, I am looking for a parsing in perl script which will parse DJEČJI SVIJET. There is a unicode character above character C. How to parse the total DJEČJI SVIJET in perl. Regards, Harikrishna (3 Replies)
Discussion started by: Harikrishna
3 Replies

9. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

10. Shell Programming and Scripting

parsing problem with script

I'm trying to parse the variables out of a comma delimited expression, but i'm having trouble with script: num_var=1 while do a=`echo "a=7, b=8, c=9" | awk '{print $num_var}' | cut -d= -f2` b=`echo $a | cut -d, -f1` echo $b num_var=`expr $num_var + 1`... (5 Replies)
Discussion started by: mike@freddiemac
5 Replies
Login or Register to Ask a Question