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 > Operating Systems > SUN Solaris
.
google unix.com



SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems .

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Check existence of a login xavier054 UNIX for Advanced & Expert Users 10 03-06-2008 11:19 AM
Csh to check for existence of file Raynon Shell Programming and Scripting 9 12-05-2007 09:20 PM
How to check process/cpu utilisation thru unix shell scripting manas_ranjan UNIX for Dummies Questions & Answers 0 07-25-2007 04:00 PM
Variable check for existence ? samit_9999 UNIX for Dummies Questions & Answers 2 12-05-2006 05:15 PM
check for FILES existence mpang_ Shell Programming and Scripting 3 06-28-2006 06:51 AM

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

Join Date: Sep 2007
Posts: 18
Exclamation How to check the file existence using shell scripting in Solaris-10

Hi,

I have a script which will check the fiel existence, the lines are as below

if !(test -d ./data) then
mkdir data
fi


In the first line error occurs as below

generatelicense.sh: syntax error at line 2: `!' unexpected

Where as this script works fine in linux OS.

How to solve it?............................


Regards
Revathi
  #2 (permalink)  
Old 11-24-2007
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,912
Your code does not work with the Bourne shell (/bin/sh) which is the default shell on most UNIX systems. This is the case for Solaris.

To maximize shell script portability, you should try and write all your shell scripts so that they work with the Bourne shell.

The following works:

Code:
if [ ! -d ./data ]
then
    mkdir data
fi
As an aside it is good practice to use fully qualified pathnames i.e. /usr/bin/mkdir instead of just mkdir.
  #3 (permalink)  
Old 11-26-2007
krevathi1912 krevathi1912 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 18
Thumbs up

Quote:
Originally Posted by fpmurphy View Post
Your code does not work with the Bourne shell (/bin/sh) which is the default shell on most UNIX systems. This is the case for Solaris.

To maximize shell script portability, you should try and write all your shell scripts so that they work with the Bourne shell.

The following works:

Code:
if [ ! -d ./data ]
then
    mkdir data
fi
As an aside it is good practice to use fully qualified pathnames i.e. /usr/bin/mkdir instead of just mkdir.

That's correct.
It works fine..............

Thanks
Revathi
Sponsored Links
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 03:19 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