What's wrong with this simple statement?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What's wrong with this simple statement?
# 1  
Old 03-03-2005
What's wrong with this simple statement?

I know that this is a ridiculously simple statement, but I am getting an error when I execute it, and I can't figure out what it is. Can anyone point me in the right direction?

Code:
#!/bin/ksh
integer dateMonth=0
integer intZero=0
if [$dateMonth == $intZero]
  then
    dateMonth = 1
fi
echo $dateMonth

# 2  
Old 03-03-2005
if [$dateMonth == $intZero]

needs to be

if [ $dateMonth == $intZero ]

Notice the spaces after "[" and preceeding "]"

Thomas
# 3  
Old 03-03-2005
I've actually tried that, with no success. The error I get is "dateMonth: not found". It then proceeds to echo "0".
# 4  
Old 03-03-2005
dateMonth = 1

No spaces around the equals sign
# 5  
Old 03-03-2005
When I take out those spaces, the error I get is "[0: not found". And then it still proceeds to echo "0".
# 6  
Old 03-03-2005
Sorry I didn't notice this as well.

dateMonth = 1

needs to be

dateMonth=1

Thomas
# 7  
Old 03-03-2005
either

if [ $dateMonth -eq $intZero ]

OR

if (( dateMonth = intZero ))
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Whats wrong with this If statement?

Hi I am pretty new to bash scripting.I am trying to write the if statement in bash and it give me error. Can you please help me what I am doing wrong in If statement? if && && then fector=$kk; divide=$DB_SIZE/$kk; echo "factor value:$fector" echo"divide value:$divide"... (4 Replies)
Discussion started by: Gevni
4 Replies

2. UNIX for Beginners Questions & Answers

Whats wrong with this If statement?

Hi I am pretty new to bash scripting.I am trying to write the if statement in bash and it give me error. Can you please help me what I am doing wrong in If statement? if && && then fector=$kk; divide=$DB_SIZE/$kk; echo "factor value:$fector" echo"divide value:$divide"... (1 Reply)
Discussion started by: Gevni
1 Replies

3. Programming

Whats wrong with this If statement?

Hi I am pretty new to bash scripting.I am trying to write the if statement in bash and it give me error. Can you please help me what I am doing wrong in If statement? Code: if && && then fector=$kk; divide=$DB_SIZE/$kk; echo "factor value:$fector" echo"divide... (1 Reply)
Discussion started by: Gevni
1 Replies

4. Shell Programming and Scripting

What is wrong with this awk statement?

echo $line | awk -F, "BEGIN {if(NF==10) && /'"${MONTH}"' '"${DAY}"' '"${TIMEH}:"'/,0 {print $10"-"$4} else {print $13"-"$4}}" if the fields in the line is equal to 10, print the values of this specified fields "$10 and $4". if the fields in the line is anything but 10, print the values of... (5 Replies)
Discussion started by: SkySmart
5 Replies

5. 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

6. Shell Programming and Scripting

What's wrong with the do statement?

hi guys, here's the code $ cat getsums.sh #!/usr/bin/sh FILENAME=$1 DELIMITER=$2 FIRST_COL=$3 SECOND_COL=$4 SALESDATE_COL=$5 STOREID=$6 UPC=$7 GTIN=$8 PROMOID=$9 echo "" echo ".:Summation Tool:." for FILE in ${FILENAME} do (7 Replies)
Discussion started by: ramneim
7 Replies

7. Shell Programming and Scripting

Simple issue, what is wrong?

I had this working a few days ago but I since changed it. Heres the code x=1 while 1 2 3 4 5 6 1=$(ps -ef | grep process | awk '{ print $2}') if then echo "The database is accepting connections..." echo "Now I will check the next process" 2=$(ps -ef | grep process1 |... (10 Replies)
Discussion started by: jeffs42885
10 Replies

8. Shell Programming and Scripting

Something is wrong with this switch( case statement.

I started writing a script to save the files from a camera I got the other day, which mounts in /Volumes , and I got into it and started building this menu. The only problem is that the switch case is coming up as a syntax error at the parenthesis after a case. Here is the code: while : do ... (2 Replies)
Discussion started by: snakemasterAK
2 Replies

9. Shell Programming and Scripting

whats wrong with this find statement ?

cmd="find /a/technologies -name '*.jar' | grep \"Tuning/specificloader/lib\"" echo $cmd for index in `$cmd` do SL_JARS="${SL_JARS}:${index}" done gives error ==> find: paths must precede expression Usage: find but for index in... (2 Replies)
Discussion started by: crackthehit007
2 Replies

10. UNIX for Dummies Questions & Answers

What is wrong with this simple script?

The script below is supposed to list file and folder names and list the type besides each - It has no practical value - I am just trying to learn KSH (so far sounds like a bad idea!) Expected output should look like this: folder 1 *** dir *** file1 * file * The code runs but produces... (9 Replies)
Discussion started by: GMMike
9 Replies
Login or Register to Ask a Question