help with simple korn scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with simple korn scripting
# 1  
Old 01-15-2009
help with simple korn scripting

Hi,

The logic is very simple but I can't seem to make this work in Korn shell.
I need to check two files to make sure there is no errors. Each of the file will have number. For example, first file btt.txt will have 112 which is good. Second file bgg.txt will have 6 which is also good. If I see any other numbers other than 112 and 6 than we have a issue.

#!/usr/bin/ksh
LOGFILE=/tmp/btt.txt
LOGFILE2=/tmp/bgg.txt
cat $LOGFILE
if [ $LOGFILE -eq 112 ]
then echo "No Errors found"
else
echo "Error found"
fi
cat $LOGFILE2
if [ $LOGFILE2 -eq 6]
then echo "No errors found"
else
echo "Error found"
fi

Please advise. Thanks.
# 2  
Old 01-15-2009
Hope this helps:

#!/bin/ksh


LOGFILE1="/tmp/btt.txt"
LOGFILE2="/tmp/bgg.txt"

if [ `cat $LOGFILE1` -eq 112 ]
then
echo "No Errors Found In $LOGFILE1"
else
echo "Error Found In $LOGFILE1"
fi

if [ `cat $LOGFILE2` -eq 6 ]
then
echo "No Errors Found In $LOGFILE2"
else
echo "Error Found In $LOGFILE2"
fi

exit 0
# 3  
Old 01-15-2009
Thank you so much, it's working now. I need to learn so much, I worked on this for hours and I could not get it correct. You are able to solve it in minutes. :-)
# 4  
Old 01-15-2009
No problem. Just keep at it, it'll come.
# 5  
Old 01-15-2009
Quote:
Originally Posted by samnyc
Hi,

The logic is very simple but I can't seem to make this work in Korn shell.
I need to check two files to make sure there is no errors. Each of the file will have number. For example, first file btt.txt will have 112 which is good. Second file bgg.txt will have 6 which is also good. If I see any other numbers other than 112 and 6 than we have a issue.

Please put code inside [code] tags.
Quote:
Code:
#!/usr/bin/ksh
LOGFILE=/tmp/btt.txt
LOGFILE2=/tmp/bgg.txt
cat $LOGFILE
if [ $LOGFILE -eq 112 ]


All cat does is display the contents of the file. If you want to use the contents, read it into a variable:

Code:
read lf1 < "$LOGFILE"
if [ "$lf1" -eq 112 ]

Quote:
Code:
then echo "No Errors found"
else
echo "Error found"
fi
cat $LOGFILE2
if [ $LOGFILE2 -eq 6]
then echo "No errors found"
else
echo "Error found"
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dialog box in korn shell scripting

Does dialog box works on all kind of shells? I am using korn shell in Linux . For me dialog is not working :) is there any particular syntax or do we need to have particular OS version or shell env? #!/bin/ksh dialog --title "create file" \ --backtitle "shell script practice" \... (1 Reply)
Discussion started by: NarayanaPrakash
1 Replies

2. Shell Programming and Scripting

Help needed in Korn Shell scripting

#! /bin/ksh while read line do if ] ; then echo "no data" continue; fi echo "performing operation on $line" done < prg.txt (3 Replies)
Discussion started by: Juhi Kashyap
3 Replies

3. Homework & Coursework Questions

korn shell scripting

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: There is a menu driven program and there are some fields to be achived 3. Display contents of all .lst files... (3 Replies)
Discussion started by: jainitai
3 Replies

4. UNIX for Advanced & Expert Users

Comparison in Korn shell scripting

I have a scenario to implement in Korn shell script. Here it is.. I need to compare two values to see whether they are same or not. The issue is that the values coming in for comparison can be a string or an integer which can be determined during run time only. Which korn shell comparison... (2 Replies)
Discussion started by: vani123
2 Replies

5. Shell Programming and Scripting

Korn shell scripting

I am attempting to learn shell programming using o'rielly book "Learning the Korn Shell". I am finding it pretty difficult to do since the only access I have to unix boxes are running version 99 of ksh. The book utilizes ksh93 and there appear to be many differences. I can't even follow along... (2 Replies)
Discussion started by: vedder191
2 Replies

6. Shell Programming and Scripting

Question about a simple Korn script

Hi to everybody! I want to write a simple script in ksh that decrypts and encrypts using the DES algorithm. There is no builtin function in UNIX : i have found only a function in openssl but i don't understand how to use it. The script must accept in input the plaitext and the DESKEY in... (2 Replies)
Discussion started by: kazikamuntu
2 Replies

7. Shell Programming and Scripting

simple if/then issue in korn shell

When I run this, it tests to Y, but why? If I take the double quotes off of test, i get the same. # !/bin/ksh TEST="N" if ; then echo $TEST" yes" else echo "no" fi (4 Replies)
Discussion started by: guessingo
4 Replies

8. Shell Programming and Scripting

Solaris Korn Shell Scripting

I have made the following simple script: a=0 let a=$a+1 if "] then mailx -s "Up" abc@yahoo.com fi When I run the above script, I get the following error: # ./new.ksh ./new.ksh: ]: not found. Please tell me how to use if here? (6 Replies)
Discussion started by: kamaldeep1986
6 Replies

9. UNIX for Dummies Questions & Answers

Help with Korn Shell Scripting

Hi I'm new to scripting and I don't know where to start. I need to create a script that needs to look for specific files in a specific folder then I need to return the filename, the recordcount, bytecount and checksums. Then I need to write these results into a new file. I would appreciate... (2 Replies)
Discussion started by: th0123
2 Replies

10. Shell Programming and Scripting

Repost-Korn Shell Scripting

Hi, being very new to Korn Shell Scripting I am hoping that someone here can help me. I want to compare file name in scp/inbox directory to file name stored inside a file in pnt/compare directory. Hi, being very new to Korn Shell Scripting I am hoping that someone here can help me. I want to... (1 Reply)
Discussion started by: hanie123
1 Replies
Login or Register to Ask a Question