Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

bad substitution error in ksh

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 01-04-2011
clx clx is offline Forum Advisor  
Registered User
 
Join Date: Jun 2007
Last Activity: 7 September 2016, 3:41 AM EDT
Location: Mumbai, India
Posts: 1,688
Thanks: 138
Thanked 204 Times in 198 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 Unix and Linux 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 Unix and Linux 01-04-2011
clx clx is offline Forum Advisor  
Registered User
 
Join Date: Jun 2007
Last Activity: 7 September 2016, 3:41 AM EDT
Location: Mumbai, India
Posts: 1,688
Thanks: 138
Thanked 204 Times in 198 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 Unix and Linux 01-04-2011
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 5 December 2016, 10:52 PM EST
Location: Amsterdam
Posts: 11,102
Thanks: 440
Thanked 3,109 Times in 2,750 Posts
Let me guess: Solaris?
Sponsored Links
    #6  
Old Unix and Linux 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 Linux
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 02:37 AM
bad substitution Error while renaming Extension paragkhanore Shell Programming and Scripting 6 06-09-2010 01:45 PM
Difference between "Command substitution" and "Process substitution" royalibrahim Shell Programming and Scripting 3 12-15-2008 11:20 AM
help with awk substitution daytripper1021 Shell Programming and Scripting 3 09-08-2008 10:58 PM
Variable substitution error cosec Shell Programming and Scripting 4 12-12-2007 04:40 AM



All times are GMT -4. The time now is 01:44 AM.