Ksh problem in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ksh problem in script
# 1  
Old 08-23-2006
Ksh problem in script

Hi

I made a small script which uses ksh.

Quote:
#!/usr/bin/ksh

USSD_PATH=/usr/Nokia/USSD/log
LOGFILE=$USSD_PATH/ussd_nokia.log
DATE_STAMP=`date +%d%m%Y`
HOUR=`date +%H`
DAY=`date +%d`

FILE=$USSD_PATH/ussdlog$DATE_STAMP

if [ $HOUR -eq 0 ];then
PREV_HOUR=23
else
PREV_HOUR=`expr $HOUR - 1`
fi

if [ $HOUR -eq 1 ];then
echo "Date|Hour|Total Attempts|Total Successful|Total Errors|Time Out Errors|WNP Connect Errors|Other Errors" > $FILE
fi

grep "|$DAY-" $LOGFILE| grep "|$PREV_HOUR:" > $USSD_PATH/temp1

restart_time=`grep "success connecting to NRH server" $USSD_PATH/temp1 | cut -d"|" -f3`

if [ -z "$restart_time" ];then
echo "USSD Restarted at $restart_time" >> $FILE
fi

ENTRIES=`wc -l $USSD_PATH/temp1|awk '{print $1}'`
SUCCESS=`grep " TEMPORARY FIX" $USSD_PATH/temp1 | wc -l`
TIMEOUT=`grep "no response from NRH" $USSD_PATH/temp1 | wc -l`
WNP=`grep "detected WNP layer error" $USSD_PATH/temp1 | wc -l`
OTHER=$((ENTRIES-(SUCCESS+TIMEOUT+(WNP*3))))
TOTAL=$((SUCCESS + $TIMEOUT + WNP + OTHER))
ERRORS=$((TIMEOUT + WNP + OTHER))
echo "$DAY|$PREV_HOUR|$TOTAL|$SUCCESS|$ERROR|$TIMEOUT|$WNP|$OTHER" >> $FILE

When i run the script then i get the following error

Quote:
stats.sh: syntax error at line 34: `OTHER=$' unexpected
However when i run each of the commands on the commandline they get executed and provide the desired output. i cant figure out why the script is not running.

Kindly Help

Thanks in advance

Last edited by PradeepRed; 08-23-2006 at 09:03 AM..
# 2  
Old 08-23-2006
I don't get that error when I try your script. Make sure that you are running it correctly. That error will happen if the old bourne shell was to try to run this script.
# 3  
Old 08-23-2006
I'm sorry if it's obvious but you might have a bad invisible character in there, if the script has ever been near a Windows machine. Try running it through dos2unix to clean it up
# 4  
Old 08-24-2006
Hi

I tried your suggestion S. but it didn't make any difference.
Perdarbo i am running my script in ksh. Like i said, if i run it line by line on the command line, it works perfectly well. However, even when i log in to ksh and run it from there, it still throws up the same error.
Its got me stumped. Smilie

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

problem in Executing script in ksh

Hi, I am in ksh. below mentioned 3 commands I executed at command prompt & got the expected results. csh source csh_infa <special command> Now I have to do this in the script in ksh. I entered it as it is. #!/bin/ksh csh source csh_infa <special command> Now after... (1 Reply)
Discussion started by: girish_kanak
1 Replies

2. Shell Programming and Scripting

Read format problem in ksh script

I have ksh script reading file like while read -r line do echo $line sleep 1 #process_file $line done<$file_nm I want to write this line to another file after some manuplation.Put $line giving me line after changing line format(space removed).Please help me how can i read line by... (3 Replies)
Discussion started by: Mandeep
3 Replies

3. Shell Programming and Scripting

Problem with KSH script using scalar variable

Hi Guys, I'm having a hard time bringing out my desired output from my korn shell script. This particular statement from my script its seems not working perl -ne 'print if $_ lt ${date1}' . My complete script as shown below. Please help. Code: #!/usr/bin/ksh ... (5 Replies)
Discussion started by: victorneri
5 Replies

4. Shell Programming and Scripting

Problem with script: ksh not found

Hello Guys, what is the significance of using #!/bin/sh at the start of shell script. my default shell is ksh, when i run my script i have ksh: not found error and when i use ./myscript it works. Can anyone explain me the problem please ? tnx (1 Reply)
Discussion started by: midhun_u
1 Replies

5. UNIX for Dummies Questions & Answers

script sourcing problem (ksh)

I have a script "abc.sh" in /tmp which has exit 0 as its last line when I run this script from /tmp/xyz/def.sh script as . ../abc.sh then the script executes but the control doesn't return to def.sh script for subsequent commands in def.sh but if I invoke the abc.sh from inside the... (3 Replies)
Discussion started by: rakeshou
3 Replies

6. AIX

Problem in ksh script ( String comparison )

hi , i am trying to compre two strings if ] or if ] when the length of var1 is small (around 300-400 char ) it works fine but when it is large (around 900-1000 chars) it fails is there any limitations for this type of comparison ??? (1 Reply)
Discussion started by: amarnath
1 Replies

7. Shell Programming and Scripting

Problem in ksh script ( String comparison )

hi , i am trying to compre two strings if ] or if ] when the length of var1 is small (around 300-400 char ) it works fine but when it is large (around 900-1000 chars) it fails is there any limitations for this type of comparison ??? (3 Replies)
Discussion started by: amarnath
3 Replies

8. Shell Programming and Scripting

Newbie problem with ksh script

Hi all, I have a directory have all of the .stat and .dat file : they are is a pipe separate flat file. Example: log-20061202.stat contain 1st line and last line of log-20061202.dat with record count of that day. Example: Total record = 240 Tom|02-12-2006|1600 W.Santa... (18 Replies)
Discussion started by: sabercats
18 Replies

9. Shell Programming and Scripting

Simple ksh script problem

This is a search script that I have developed. It finds the records that I look for. However the only thing I want the program to do now is to display a message such as 'Not Found' to appear when a record is not found. So far when a search doesn't display a record, the screen is blank. ... (14 Replies)
Discussion started by: Warrior232
14 Replies

10. Shell Programming and Scripting

ksh script and java problem

I have a problem with the execution of a ksh as deamon on linux. I explain you first the context. We have developped a Java program that execute every minutes an external (that we don't have developped) program with a config file in parameter. The Java program is runned as deamon with a perl... (0 Replies)
Discussion started by: adrian.mihai
0 Replies
Login or Register to Ask a Question