What's wrong with my script ....


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What's wrong with my script ....
# 1  
What's wrong with my script ....

Please see below mentioned my script ... it ran once without any issue .... then after it is not coming out .... please suggest what is wrong?

Code:
#!/bin/ksh
## if (( ${num_errors} > 0 ));
export ACULOG=/home/varshnes/input
export num_errors=10
**** Search for 'Start correcting roll up conflicts' ****
STRING=$(find $ACULOG -name "*" | xargs grep -i "Start" | grep -i "correcting" | wc -l)
echo $STRING
 if (( ${STRING} > 0 ));
 then
 echo -n "$num_errors "
 num_errors=`expr $num_errors - 1`
 fi
STRING=$(find $ACULOG -name "*" | xargs grep -i "End" | grep -i "correcting" | wc -l)
echo $STRING
 if (( ${STRING} > 0 ));
 then
 echo -n "$status "
 num_errors=`expr $num_errors - 1`
 fi
echo -n "$num_errors "
 if (( ${num_errors} > 0 ));
 then
 echo "SEND MAIL NOW"
 fi
exit 0


Last edited by Scott; 05-20-2010 at 06:28 PM.. Reason: Code tags please...
# 2  
Can you post the errors that you face?
The script looks fine assuming your 5th line as an comment line.
# 3  
5th line is not an acceptable comment line...needs to be preceded with a hash/#-sign.
# 4  
What's wrong with my script ....

There is not any error ... it is simply not doing anything ... not coming out either. it ran once and do not know what I did and it has stoped working ... please suggest ..thx
# 5  
right, because it gets to the 5th line and it starts trying to use globbing...for no reason, and stalls.

Comment out the 5th line...and maybe even redirect the script itself to 2>&1, and you may get it to run.
# 6  
That was corerct ...removed *'s and it works fine ... a quick question though ...
the line ...
Code:
STRING=$(find $ACULOG -name "*" | xargs grep -i "Start" | grep -i "correcting" | wc -l)

Can it by write in different style? I'm trying to grep complete line here.

Thanks!

Moderator's Comments:
Mod Comment Added code tags
# 7  
I'm not sure what you mean by grep complete line...? Looks like you're just grabbing any line in any file in that directory that contains "Start", and then counting only those that also contain "correcting"...

I would suggest maybe the following if you're looking for a more compact approach:
Code:
typeset -i STRING=$(find $ACULOG -name "*" |xargs grep -i "Start" |grep -c "correcting" )

Otherwise, if you mean to return the entire line, then you'd want to just stop counting:
Code:
COMP_LINE=$(find $ACULOG -name "*" |xargs grep -i "Start" |grep -i "correcting" )

Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #669
Difficulty: Medium
802.11 technology has its origins in a 1985 ruling by the U.S. FCC that released the ISM band for unlicensed use.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why result is wrong here ? whether break statement is wrong ?

Hi ! all I am just trying to check range in my datafile pls tell me why its resulting wrong admin@IEEE:~/Desktop$ cat test.txt 0 28.4 5 28.4 10 28.4 15 28.5 20 28.5 25 28.6 30 28.6 35 28.7 40 28.7 45 28.7 50 28.8 55 28.8 60 28.8 65 28.1... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies

2. Shell Programming and Scripting

What is wrong with my script?

Dear All The following is part of my script: echo ${myarray} mytitle=`awk '{print substr(${myarray}, 0, length(${myarray})-4)}' /dev/null` the echo ${myarray} works fine; however, I keep getting following error for the mytitle=.. part: awk: line 1: syntax error at or near { awk: line... (3 Replies)
Discussion started by: littlewenwen
3 Replies

3. Shell Programming and Scripting

What is wrong with this script

Good day all I have a UNIX script that I created to set a couple of environment variables for my Oracle installation. When I initially run the script, I get the correct values on the inbuilt echo command but when the script completes and I issue an echo statement echo $ORACLE_SID, the... (9 Replies)
Discussion started by: tt1611
9 Replies

4. Shell Programming and Scripting

ps script - What is wrong with it please?

Hi All, I am trying to do a script that prompts the user for the PID and it displays information about that process, this is what I have, but is not working: echo "Please enter your PID:" read pid case $pid in ps | grep $pid esac done * I also needed that this... (1 Reply)
Discussion started by: linuxrose
1 Replies

5. Shell Programming and Scripting

Script Gone Wrong

Hello all, so this is a script i did for an assignement, - first option greets the user according to the time after fetching his name - second options isn't implemented - third check the performance according to how many users are using the system - creates a log of names, time and ip of the... (14 Replies)
Discussion started by: ibzee33
14 Replies

6. Shell Programming and Scripting

what is wrong with this script?

Hi I've made a short script but it is not working. Can some pl. help me out in this? ./123.sh #! /usr/bin/ksh # for changing to this directory cd /layered/relational/scripts When I run the above scripts, it doesn't change to the above directory. I don't what is the problem? the... (2 Replies)
Discussion started by: Mike1234
2 Replies

7. Shell Programming and Scripting

what is wrong with this script?

why??? I don't get it.. while read line do count=$(ping -c 3 $line | grep 'received' | awk -F ',' '{print $2}' | awk '{print $1}') if ; then echo "Host: $line is down" else echo "Host: $line is up" fi done<host.list sh -x ./hoststatus ./hoststatus: syntax error at line... (8 Replies)
Discussion started by: hankooknara
8 Replies

8. Shell Programming and Scripting

What is wrong with this script?

I keep getting errors messages for the "else" statement at line 81? #!/bin/ksh ######### Environment Setup ######### PATH=/gers/nurev/menu/pub/sbin:/gers/nurev/menu/pub/bin:/gers/nurev/menu/pub/mac :/gers/nurev/menu/adm/sbin:/gers/nurev/menu/adm/bin:/gers/nurev/menu/adm/mac:/ge... (8 Replies)
Discussion started by: heprox
8 Replies

9. Shell Programming and Scripting

something wrong with this script??

Ok I'm writing a script that will do the following: 1) grep lines from a log file and output the grepped data to a file 2) cut a column range from the grepped output file 3) take the column of info that i cut and use uniq to tell the duplicates here is what I wrote so far but I can't get it... (2 Replies)
Discussion started by: fusion76
2 Replies

10. Shell Programming and Scripting

What is wrong with this script?

Hi, Basically, i am reading a file and transferring files between two servers using sftp. I am checking the last character of the file which gives me the server number to transfer the file to..After i check the server number and try to include the sftp code....it gives me am error syntax... (5 Replies)
Discussion started by: borncrazy
5 Replies

Featured Tech Videos