Need assistance to resolve the KSH issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need assistance to resolve the KSH issue
# 1  
Old 11-16-2009
Need assistance to resolve the KSH issue

am running the small script below.

count_a=48
count_b=48
if [$count_a -eq $count_b]; then
echo "Count matched"
else
echo "count not matched"
fi

I got the below output.

/bin/ksh: [48: not found
count not matched

It was giving the same error when I ran in another box. But I inculded /bin/ksh in the 1st line. Then It was working fine.
But same way I followed here also. even it is giving error.

And I tried the way also as I added #!/bin/ksh in the 1st line. But not favour.

my /bin/*sh output is given below.

-rwxr-xr-x 1 root other 703 Dec 16 2004 /bin/gnome-autogen.sh
-r-xr-xr-x 17 root bin 134 Jan 21 2005 /bin/hash
-r-xr-xr-x 1 root bin 735572 Jan 23 2005 /bin/bash
-r-------- 1 root bin 27752 Jan 23 2005 /bin/rsh
-r-xr-xr-x 2 root bin 159592 Jan 23 2005 /bin/pfcsh
-r-xr-xr-x 2 root bin 159592 Jan 23 2005 /bin/csh
-r-xr-xr-x 3 root bin 209256 Jan 23 2005 /bin/rksh
-r-xr-xr-x 3 root bin 209256 Jan 23 2005 /bin/pfksh
-r-xr-xr-x 3 root bin 209256 Jan 23 2005 /bin/ksh
-r-xr-xr-x 1 root bin 257288 Jan 23 2005 /bin/ssh
-r-xr-xr-x 1 root bin 363280 Jan 23 2005 /bin/tcsh
lrwxrwxrwx 1 root root 13 Jan 11 2006 /bin/jsh -> ../../sbin/sh
lrwxrwxrwx 1 root root 13 Jan 11 2006 /bin/pfsh -> ../../sbin/sh
lrwxrwxrwx 1 root root 13 Jan 11 2006 /bin/sh -> ../../sbin/sh
lrwxrwxrwx 1 root root 5 Jan 11 2006 /bin/remsh -> ./rsh
lrwxrwxrwx 1 root root 14 Jan 11 2006 /bin/zsh -> ../sfw/bin/zsh
lrwxrwxrwx 1 root other 28 Mar 2 2006 /bin/rpccp.sh -> /opt/OV/dce/bin_exe/rpccp.sh


Pls help me.
# 2  
Old 11-16-2009
It's the old "missing spaces either side of the [ and ]" one

Code:
if [ $count_a -eq $count_b ]; then

Not really sure what you're trying to say here:
Quote:
It was giving the same error when I ran in another box. But I inculded /bin/ksh in the 1st line. Then It was working fine.
But same way I followed here also. even it is giving error.

And I tried the way also as I added #!/bin/ksh in the 1st line. But not favour.
# 3  
Old 11-16-2009
Add some spaces:
Code:
count_a=48
count_b=48
if [ $count_a -eq $count_b ]; then
  echo "Count matched"
else
  echo "count not matched"
fi

# 4  
Old 11-16-2009
Thanks guys.

Yes. the problem was the space . Now it is working fine.
# 5  
Old 11-16-2009
Remember that the "[ ]" is an alias of the "test" command.
# 6  
Old 11-16-2009
Thank you very much.

Can you pls tell me how can I find the current_date+6days date? I mean if I run a script today it should print 22/11/2009.

Important thing is it should work for all the years including leap year.

I need your help for the below activity. (currently it should print the today date)

dat=`date '+%m/%d/20%y'`
partition_date=`date|awk '{print $2$3}'`
new_partition=SAS_AUDIT_$partition_date
echo "The new partition name is "$new_partition""
echo "alter table AUDIT_TRAIL split partition partmax at (to_date('$dat 00:00:00','mm/dd/yyyy hh24:mi:ss')) into (partition
$new_partition,partition partmax);" | sqlplus -s username/pwd
# 7  
Old 11-16-2009
Code:
date '+%m/%d/20%y'


returns the current date
try
Code:
date now +6 days '+%m/%d/20%y'

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh while read issue

Hello, I have used a chunk of ksh script similar to this in many places without any issue: while : do print; read OPTION?"Enter a number (q to quit): " expr ${OPTION} + 1 >/dev/null 2>&1 CHECKVAL=$? if }" != ${OPTION} ]; then ... (2 Replies)
Discussion started by: port43
2 Replies

2. Shell Programming and Scripting

Need assistance in ksh script

requirement : I need to read a text file and find out which particular line has highest charcters on it using the shell script. I tried & was able to find out only for one line. I could not able to find out for the entire the line. sed -n '10 p' ctstest.sh | wc -w Please guide me... (5 Replies)
Discussion started by: ramkumar15
5 Replies

3. Solaris

Cannot resolve PTR record issue

Hi guys, I am currently receiving the following output in /var/log/syslog and is occurring every second leading to /var directory being full after every 2 days. Aug 20 17:32:29 opaldn1 sendmail: r7KCOlQm002517: ruleset=check_rcpt, arg1=<postmaster@silverapp6>, relay=, reject=450 4.4.0... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies

4. Shell Programming and Scripting

-z in ksh issue

Hi, Can any body please tell me what does -z do in ksh? I need to understand what does below code do? FILE_LIST is an array which store multiple number of files... if } ]]; then echo "EVDO file not found fi I hope I'm clear on my query (3 Replies)
Discussion started by: annybase
3 Replies

5. Shell Programming and Scripting

Need assistance with a file issue and a terminal issue

Hello everyone, I'm in need of some assistance. I'm currently enrolled in an introductory UNIX shell programming course and, well halfway through the semester, we are receiving our first actual assignment. I've somewhat realized now that I've fallen behind, and I'm working to get caught up, but for... (1 Reply)
Discussion started by: MrMagoo22
1 Replies

6. Shell Programming and Scripting

ksh: How do I resolve ip addr in a text file?

Hi, I need to resolve IP to names in a text file. I was thinking of using some unix commands. Ksh. Text in file contains a lot of these entries: .. 20 6 <166>%ASA-6-302013: Built inbound TCP connection 12690562 for inside2:10.86.6.20/3678 (10.86.6.20/3678) to inside:10.107.22.12/1947... (3 Replies)
Discussion started by: hasselhaven
3 Replies

7. Shell Programming and Scripting

basename issue with ksh

I have a function name called help as below function help { echo "Run the script as," #echo "$(basename $0) -sod or -eod" echo "${0##*/} -sod or -eod" } and have case stmt which will call this function incase of wrong parameter but when ever I'm giving wrong... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

8. UNIX for Dummies Questions & Answers

Can any good awk'er resolve this issue?

awk -F^ '{ if ((($1 != "M") && ($5 != "2")) || (($1 != "S") && ($5 != "7"))) print $0}' welcome > welcome1 The "&&" and "||" in the above command is not working with awk. When I run the above command, the same content of welcome is copied to welcome1 without any difference. Your reply is... (12 Replies)
Discussion started by: karthickrn
12 Replies

9. Shell Programming and Scripting

KSH Script Assistance

Hey everyone, I'm newer than new when it comes to this ksh and scripting stuff, and unix in general. I have been thrown into a task at work that A: They expect me to come up to speed on, B: Show I can do this. (Program for the workgroup) Here's the script, part of it, from the overall... (3 Replies)
Discussion started by: Brusimm
3 Replies
Login or Register to Ask a Question