Simple program but problem-pls Help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Simple program but problem-pls Help
# 8  
Old 07-08-2008
Hi namishtiwari and zaxxon and all,
I really appreciate your patience...

Thank You ur code worked.

but it was just a sample code given.my actuall program is NOT working.
i wanted/used the same concept in one of my module of a Huge program.

here is my actual code,i wonder y it's not working.
the concept is same as our sample code.

#!/bin/sh
egrep '(Latch Hit)...' /oracle/zaheer/parts/part4 | awk '{print "Latch Hit "$9 " %"}'
set value=99
if [ $9 -lt $value ] ;
then
echo "Your latch it is $9 It is very is Low"
else
echo "You Have $9 latch hit which is Very Good"
fi


output:
$ ./latch.sh
Latch Hit 100.00 %
Your latch it is It is very is Low

Again wrong loop,again witout $9 value. YYYYY?i dont know...IM GOING MAD.

Please help me here....
# 9  
Old 07-08-2008
why are you using set here remove set and give a try.

set value=99 -> remove set

Thanks
Namish
# 10  
Old 07-08-2008
Hi namishtiwari,

If i remove set im getting the error..
and if i put "set" it's executing wrong loop...Oh God.

code:
egrep '(Latch Hit)...' /oracle/zaheer/parts/part4 | awk '{print "Latch Hit "$9 " %"}'
value=99
if [ $9 -lt $value ] ;
then
echo "Your latch it is $9 It is very is Low"
else
echo "You Have $9 latch hit which is Very Good"
fi

output:
$ ./latch.sh
Latch Hit 100.00 %
./latch.sh: test: argument expected


PLS HELP ME....
It's Urgent.. and Im going MAD hour after Hour....

Thanks
# 11  
Old 07-08-2008
you are using the arguement $9 but where you are passing the value of that to the script.

Thanks
# 12  
Old 07-08-2008
Nearly there. The $9 to awk means the 9th field in the input stream to awk. It is not the same as $9 in shell - the 9th parameter in the shell call.
Just save the percentage value, then format the output. Note the left sloping quotes around the egrep command sequence.
I've also deleted a ";" from the "if" statement.
(Script is untested but should show you the way).

#!/bin/sh
latch_hit=`egrep '(Latch Hit)...' /oracle/zaheer/parts/part4 | awk '{print $9}'`

set value=99

if [ ${latch_hit} -lt $value ]
then
echo "Your latch it is ${latch_hit} It is very is Low"
else
echo "You Have ${latch_hit} latch hit which is Very Good"
fi


Footnote:
Awk purists will be able to set $latch_hit with just awk commands.
# 13  
Old 07-09-2008
Hi Methyle and All,
if u execute the following code:
Quote:
#!/bin/sh
latch_hit=`egrep '(Latch Hit)...' /oracle/zaheer/parts/part4 | awk '{print $9}'`

set value=99

if [ ${latch_hit} -lt $value ]
then
echo "Your latch it is ${latch_hit} It is very is Low"
else
echo "You Have ${latch_hit} latch hit which is Very Good"
fi
i get the following error:

$ l.sh
l.sh: test: argument expected

Please HELP
# 14  
Old 07-09-2008
You should play around testing your with your shell and the test command, if you better use 1 or 2 brackets on each side, which kind of arithmetic operators you can use (-eq, -gt, <=, ==, =, <>, ...) and if you can use something similar to typeset to declare variable values as integer for example, which your shell doesn't seem to know.

I tried sh/bash, ksh and each of them knows "typeset" for example. What OS are you on and what kind of shell are you using (I saw the shebang, but check the package's/binary's version maybe)?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

A simple C program query ...

Given the following code inside the function ext3_write_super(): (It's there in Linux kernel 2.6.27.59) static void ext3_write_super (struct super_block * sb) { if (mutex_trylock(&sb->s_lock) != 0) BUG(); sb->s_dirt = 0; } The conditional test at if... (2 Replies)
Discussion started by: Praveen_218
2 Replies

2. UNIX for Dummies Questions & Answers

Help with creating a simple program!!

i am new to shell scripting!! i am making this program in bourne shell, that asks the user to input "Hello (their name)" or "question (their name)", any other input, "ERROR" will be outputted. if they input "Hello (name)", i want to out saying Hello (name) but if they input "question (name)", i... (4 Replies)
Discussion started by: bshell_1214
4 Replies

3. Shell Programming and Scripting

Help with simple program. (beginner)

Hey all, Writing a program that searches for a username and if they are online creates a 'beep' and sends the username and date to a log file. the error i am getting is: paul.obrien16@aisling:~/os$ bash checklogin : command not found Enter username paul.obrien16 ': not a valid... (2 Replies)
Discussion started by: sexyladywall
2 Replies

4. Shell Programming and Scripting

Shell program help pls

first queestion if what does "-s" mean? second seqx -n 10000000 -c 10 < $seqfile >$temp seqx? -n? -c? what do these mean? third if && ! cmp -s $missing $temp explain these codes ty (2 Replies)
Discussion started by: imtheone
2 Replies

5. Shell Programming and Scripting

simple program help required

The circumfrence of a circle is #!/usr/bin/perl print 2 * 3.141592654 * 12.50 \n"; # pi= 3.141592654 # r= 12.50 I need a simple program showing me all the steps..to modify the above to prompt for and accept a radius from the person running the... (3 Replies)
Discussion started by: Q2wert
3 Replies

6. Programming

Xlib simple program.

I don't know if it is right to ask you this. Can someone help me write a simple Xlib program,with button on it,and all that button do is switch 2 messages. I have tried and tried,but never get past Hello World. Can someone help me please? ---------- Post updated at 10:17 PM ---------- Previous... (2 Replies)
Discussion started by: megane16v
2 Replies

7. Shell Programming and Scripting

Problem.. can someone pls help..

Hi All, My file contains data like below. Key ~PILCSZY First Name Szymon Surname Pilch User Code Group SCO-PL User Group Description SCO - Poland Key ... (2 Replies)
Discussion started by: harshakusam
2 Replies

8. Programming

a simple chat program

any suggestions on how i could create a simple chat program between two terminals using pipes? thanks (1 Reply)
Discussion started by: kelogs1347
1 Replies

9. Shell Programming and Scripting

HELP me PLS... Simple Scripting!

this is my script.... SQL> select * from dba_profiles 2 where resource_name in ('FAILED_LOGIN_ATTEMPTS','PASSWORD_LOCK_TIME') 3 order by profile; and this is the output... PROFILE RESOURCE_NAME RESOURCE... (2 Replies)
Discussion started by: liezer
2 Replies

10. Programming

QUESTION...simple program?

I am new to the unix/linux environment. AND........ I need to create a mini shell..that displays prompt (i.e., READY:$), accepts a command from std-in, and prints the command and any parameters passed to it. HELP!!!! (8 Replies)
Discussion started by: jj1814
8 Replies
Login or Register to Ask a Question