bad substitution error in ksh | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

bad substitution error in ksh

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-04-2011
adshocker adshocker is offline
Registered User
 
Join Date: Jun 2009
Last Activity: 21 January 2014, 8:58 PM EST
Posts: 35
Thanks: 19
Thanked 0 Times in 0 Posts
bad substitution error in ksh

hi,

i created a shell script having the following content:


Code:
#! /usr/bin/ksh
FROM="myemail@domain.com"
MAILTO="someemail@domain"
SUBJECT="TEST"
BODY="/export/home/adshocker/body.txt"
ATTACH="/export/home/adshocker/attach.prog"
echo $ATTACH
ATTACH_NAME="${ATTACH##*/}"
echo $ATTACH_NAME

if i then execute it using the following, i get the bad substitution error.


Code:
$ sh smail.sh
/export/home/adshocker/attach.prog
smail.sh: bad substitution

if i echo it directly its okay.

can someone help me solve this.

thanks
Sponsored Links
    #2  
Old 01-04-2011
clx clx is offline Forum Advisor  
Registered User
 
Join Date: Jun 2007
Last Activity: 31 October 2014, 3:58 AM EDT
Location: Mumbai, India
Posts: 1,614
Thanks: 125
Thanked 184 Times in 178 Posts
The above is working for me.
May be your bourne shell is older? There is nothing to do with ksh (the shebang) here since you are invoking script with command line shell. (sh)

try invoking with "ksh" or execute the script "./smail.sh" (after giving execute permission)
The Following User Says Thank You to clx For This Useful Post:
adshocker (01-04-2011)
Sponsored Links
    #3  
Old 01-04-2011
adshocker adshocker is offline
Registered User
 
Join Date: Jun 2009
Last Activity: 21 January 2014, 8:58 PM EST
Posts: 35
Thanks: 19
Thanked 0 Times in 0 Posts
hi,

thanks for the quick response.

i tried as you suggested.


Code:
ksh smail.sh
./smail.sh

both are working fine without any errors.

does that mean i have an older version of shell that prevented me from using sh?

thanks.
    #4  
Old 01-04-2011
clx clx is offline Forum Advisor  
Registered User
 
Join Date: Jun 2007
Last Activity: 31 October 2014, 3:58 AM EDT
Location: Mumbai, India
Posts: 1,614
Thanks: 125
Thanked 184 Times in 178 Posts
Quote:
Originally Posted by adshocker View Post
does that mean i have an older version of shell that prevented me from using sh?
You probably have older version of bourne shell in which string operations doesn't work.
When you say "sh" that means bourne shell.
Sponsored Links
    #5  
Old 01-04-2011
Scrutinizer's Avatar
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 31 October 2014, 2:05 AM EDT
Location: Amsterdam
Posts: 9,561
Thanks: 286
Thanked 2,430 Times in 2,177 Posts
Let me guess: Solaris?
Sponsored Links
    #6  
Old 01-04-2011
adshocker adshocker is offline
Registered User
 
Join Date: Jun 2009
Last Activity: 21 January 2014, 8:58 PM EST
Posts: 35
Thanks: 19
Thanked 0 Times in 0 Posts
thanks.

and yes it's solaris
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
bad substitution error in ksh LiorAmitai Shell Programming and Scripting 2 01-06-2011 01:37 AM
bad substitution Error while renaming Extension paragkhanore Shell Programming and Scripting 6 06-09-2010 12:45 PM
Difference between "Command substitution" and "Process substitution" royalibrahim Shell Programming and Scripting 3 12-15-2008 10:20 AM
help with awk substitution daytripper1021 Shell Programming and Scripting 3 09-08-2008 09:58 PM
Variable substitution error cosec Shell Programming and Scripting 4 12-12-2007 03:40 AM



All times are GMT -4. The time now is 07:24 AM.