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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Is there any Javascript things for Lynx? zeus Security 7 11-10-2007 09:56 PM
Question about several things in C V4D3R High Level Programming 1 09-13-2007 10:56 PM
When things doesn't run into crontab??? nymus7 Shell Programming and Scripting 4 04-24-2006 11:11 AM
Complicating things? bconnor High Level Programming 1 03-30-2006 10:07 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-27-2005
forevercalz forevercalz is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 74
how to convert things from csh to sh

i have this method in csh that check for file exist.


#check that file exists
if ( ! -e $6$5 ) then
echo $6$5 Not Found
exit 8
endif

however i wanted in to be in just sh. so i change the code to:
if [ ! -e $6$5 ]; then
echo $6$5 Not Found
exit 8
fi

I get error showing test arguments needed or something like this..is there any problem with my coding? Btw the parameters are passed in...$5 is a text file and $6 is a path name.
  #2 (permalink)  
Old 10-28-2005
Unbeliever Unbeliever is offline
Registered User
  
 

Join Date: Jul 2005
Location: England
Posts: 183
Put quote around the variable argument in the if staement. eg

if [ ! -e "$6$5" ]

The reason you get an error in your own code when $5 and $6 are both empty is that the '-e' test requires an argument. By putting quotes round it you force an argument of a null string (rather than no argument at all) when $5 and $6 are both empty.

Last edited by Unbeliever; 10-28-2005 at 10:06 AM..
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:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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