?
Solved

HP-UX IF Statement

Posted on 2010-01-12
2
Medium Priority
?
3,707 Views
Last Modified: 2013-12-06
Hi! I need help with my HP-UX Script. Its been written using Korn Shell. I'm trying to compare the system date, with the first date from a text file. And IF the dates match, it gives me a "Correct". Otherwise it states "Wrong". But it doesn't seem to be working. Please advise. Script and the output result that I see is below. I made a comparison between two dates whereby both dates are of the same date, and the output result should be "Correct". But the error points to my IF statement, and I can't figure out what's wrong. Your help is much appreciated.

#!/usr/bin/ksh
 
datentime=`(date '+%Y%m%d')`
newdate=$datentime
 
phdate= head -1 /usr/users/amsbmi/tmp/ph.txt
dd=$phdate
 
if [[$newdate -eq $dd]];
then
echo "Correct";
else
echo "Wrong";
fi

__________________________________________________________________________

Output Received:

20100112
./remplc.sh[9]: [[20100112:  not found
Wrong
0
Comment
Question by:ben1211
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 26292009
#!/usr/bin/ksh
 
datentime=$(date '+%Y%m%d')
newdate=$datentime
 
phdate=$(head -1 /usr/users/amsbmi/tmp/ph.txt)
dd=$phdate
 
if [[ $newdate -eq $dd ]];
then
echo "Correct"
else
echo "Wrong"
fi
Besides the things I marked bold, please note the spaces around "[[ " and " ]]"
wmp


0
 

Author Comment

by:ben1211
ID: 26299181
Thanks wmp....it works :)
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question