The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
when executing .sh script in telnet error "script not found" smiley Shell Programming and Scripting 1 04-22-2008 02:01 PM
Error in the script krworks Shell Programming and Scripting 5 04-18-2008 02:31 AM
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 11:16 AM
Script error Katkota UNIX for Dummies Questions & Answers 3 01-22-2008 06:02 PM
error in awk script rraajjiibb Shell Programming and Scripting 7 06-10-2004 08:37 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-19-2007
Nysif Steve Nysif Steve is offline
Registered User
  
 

Join Date: Aug 2007
Location: Albany, NY
Posts: 26
Script Error if ... then

I am trying to debug a script. I am getting the error following errors from the code listed below. I am working in Korn shell in a Sun Solaris UNIX environment.

****************
** Error Message **
****************
Code:
$ statreports.sh 0030 1327
./statreports.sh[29]: if[2:  not found
./statreports.sh[30]: syntax error at line 31 : `then' unexpected

*******************
** Code Causing Error **
*******************
Code:
# Check if the second command argument is exists.
if["$#" < 2]
then
	((endTime = $startTime + 28800))		# Add 8 hours = 28800 seconds
.
.
.
fi
  #2 (permalink)  
Old 09-19-2007
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
put a space after the '[' and before the ']'
  #3 (permalink)  
Old 09-19-2007
Nysif Steve Nysif Steve is offline
Registered User
  
 

Join Date: Aug 2007
Location: Albany, NY
Posts: 26
The error still reads:

Code:
./statreports.sh[27]: if[:  not found
./statreports.sh[28]: syntax error at line 29 : `then' unexpected

Last edited by Nysif Steve; 09-19-2007 at 04:23 PM..
  #4 (permalink)  
Old 09-19-2007
kahuna's Avatar
kahuna kahuna is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 149
Quote:
Originally Posted by Nysif Steve View Post
Code:
./statreports.sh[27]: if[:  not found
In addition to the other spaces it needs a space after the "if"
  #5 (permalink)  
Old 09-19-2007
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by Nysif Steve View Post
I am trying to debug a script. I am getting the error following errors from the code listed below. I am working in Korn shell in a Sun Solaris UNIX environment.

****************
** Error Message **
****************
Code:
$ statreports.sh 0030 1327
./statreports.sh[29]: if[2:  not found
./statreports.sh[30]: syntax error at line 31 : `then' unexpected

*******************
** Code Causing Error **
*******************
Code:
# Check if the second command argument is exists.
if["$#" < 2]

Commands (e.g., [) and shell keywords (e.g., if) must be surrounded by whitespace:
Code:
if [ "$#" < 2 ]
Quote:
Code:
then
	((endTime = $startTime + 28800))		# Add 8 hours
= 28800 seconds

More portable is:

Code:
endTime=$(( $startTime + 28800))
Quote:
Code:
.
.
.
fi
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:41 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0