bad substitution error in ksh

hi,

i created a shell script having the following content:

#! /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.

$ 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

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)

1 Like

hi,

thanks for the quick response.

i tried as you suggested.

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.

You probably have older version of bourne shell in which string operations doesn't work.
When you say "sh" that means bourne shell.

Let me guess: Solaris?

thanks.

and yes it's solaris :slight_smile: