Sponsored Content
Top Forums Shell Programming and Scripting bad substitution error in ksh Post 302485003 by adshocker on Tuesday 4th of January 2011 12:50:01 AM
Old 01-04-2011
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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bad Substitution

Need Help... I am getting a bad substitution error on my script on a Solaris Server. However the script has been proven to work on HPUX and Solaris servers... #!/usr/bin/sh # # Set the location of the tzupdater.jar file # JAR=/tmp/tzupdater.jar # <<<<< UPDATE THIS LINE... (3 Replies)
Discussion started by: D_Redd74
3 Replies

2. Shell Programming and Scripting

bad substitution Error while renaming Extension

Hi All, We are in the process of Migrating from AIX 4 to Solaris 10 and getting a Few Errors. I have been programming in shell but could never establish muself as an expert, hence please need you help. I am Getting Bad Substitution error in my script, I have isolated the issue and its... (6 Replies)
Discussion started by: paragkhanore
6 Replies

3. Shell Programming and Scripting

bad substitution error in ksh

Hello, In bash I can use the following: TMP=12345 MID=${TMP:1:1} the expected result is: 2 but when using KSH I'm getting a ''bad substitution" error. What is the correct syntaxin ksh? Thanks (2 Replies)
Discussion started by: LiorAmitai
2 Replies

4. UNIX for Dummies Questions & Answers

bad substitution

#!/bin/bash a1=( win 12,01,02,03,04 ) a2=( pre 04,05,06 ) a3=( msn 06,07,08,09 ) Given the above arrays, I want the script to return/echo the following in a loop; win 12,01,02,03,04 pre 04,05,06,07 msn 06,07,08,09 But I can't get it to do as such. I've tried; (2 Replies)
Discussion started by: Muhammad Rahiz
2 Replies

5. Shell Programming and Scripting

bad substitution error!

Hi All, I'm building a new shell script but i'm facing a problem with one line which is giving "bad substitution" error. Please assist script lines: #!/bin/sh printf "%s: " "Occurrence DATE (YYYYMMDD)"; read DATE shortdate=${DATE#??} o/p: ./test1: bad substitution This command is... (2 Replies)
Discussion started by: Dendany83
2 Replies

6. Shell Programming and Scripting

Why I get bad bad substitution when using eval?

Why I get bad replace when using eval? $ map0=( "0" "0000" "0") $ i=0 $ eval echo \${map$i} 0000 $ a=`eval echo \${map$i}` !!!error happens!!! bash: ${map$i}: bad substitution How to resolve it ? Thanks! (5 Replies)
Discussion started by: 915086731
5 Replies

7. Shell Programming and Scripting

Bad substitution error in shell script

I have script data.sh which has following error. Script Name : data.sh #!/bin/sh infile=$1 len=${#infile} echo $len texfile=${infile:0:$len-4} echo $texfile run command ./data.sh acb.xml I get following error message: (5 Replies)
Discussion started by: man4ish
5 Replies

8. Shell Programming and Scripting

Bad substitution error while working with substring

Hi I'm using ksh. And i'm trying to get the substring like below. but giving the following error #!/bin/ksh foo=teststring bar=${foo:0:5} echo $bar And the error is ./sbstr_test.sh: bar=${foo:0:5}: bad substitution what is wrong in this script. Please correct me ... (3 Replies)
Discussion started by: smile689
3 Replies

9. Shell Programming and Scripting

ksh - Get last character from string - Bad Substitution error

I want to get the last character from my machine name using the following code, the default shell is bash, the script runs in ksh. I get 'bad' substitution error on running the script, but works fine if run using dot and space. Why? $ echo $0 bash $ cat -n myenv.sh 1 ... (8 Replies)
Discussion started by: ysrini
8 Replies

10. Shell Programming and Scripting

Bad substitution

Cant undestand :) why i have an error on line 2.it is working on my other boxes #!/bin/bash ret=$(echo Q | timeout 5 openssl s_client connect "${1`hostname`}:${2-443}" -ssl3 2> /dev/null) if echo "${ret}" | grep -q 'Protocol.*SSLv3'; then if echo "${ret}" | grep -q 'Cipher.*0000'; then ... (7 Replies)
Discussion started by: kenshinhimura
7 Replies
Mail::Message::Body::Construct(3pm)			User Contributed Perl Documentation		       Mail::Message::Body::Construct(3pm)

NAME
Mail::Message::Body::Construct - adds functionality to Mail::Message::Body DESCRIPTION
This package adds complex functionality to the Mail::Message::Body class. This functions less often used, so many programs will not compile this package. METHODS
Constructing a body $obj->attach(MESSAGES, OPTIONS) Make a multipart containing this body and the specified MESSAGES. The options are passed to the constructor of the multi-part body. If you need more control, create the multi-part body yourself. At least take a look at Mail::Message::Body::Multipart. The message-parts will be coerced into a Mail::Message::Part, so you may attach Mail::Internet or MIME::Entity objects if you want --see Mail::Message::coerce(). A new body with attached messages is returned. example: my $pgpkey = Mail::Message::Body::File->new(file => 'a.pgp'); my $msg = Mail::Message->buildFromBody( $message->decoded->attach($pgpkey)); # The last message of the $multi multiparted body becomes a coerced $entity. my $entity = MIME::Entity->new; my $multi = $msg->body->attach($entity); # Now create a new message my $msg = Mail::Message->new(head => ..., body => $multi); $obj->concatenate(COMPONENTS) Concatenate a list of elements into one new body. Specify a list of text COMPONENTS. Each component can be a message (Mail::Message, the body of the message is used), a plain body (Mail::Message::Body), "undef" (which will be skipped), a scalar (which is split into lines), or an array of scalars (each providing one line). example: # all arguments are Mail::Message::Body's. my $sum = $body->concatenate($preamble, $body, $epilogue, "-- " , $sig); $obj->foreachLine(CODE) Create a new body by performing an action on each of its lines. If none of the lines change, the current body will be returned, otherwise a new body is created of the same type as the current. The CODE refers to a subroutine which is called, where $_ contains body's original line. DO NOT CHANGE $_!!! The result of the routine is taken as new line. When the routine returns "undef", the line will be skipped. example: my $content = $msg->decoded; my $reply = $content->foreachLine( sub { '> '.$_ } ); my $rev = $content->foreachLine( sub {reverse} ); sub filled() { length $_ > 1 ? $_ : undef } my $nonempty = $content->foreachLine( &filled ); my $wrong = $content->foreachLine( sub {s/a/A/} ); # WRONG!!! my $right = $content->foreachLine( sub {(my $x=$_) =~ s/a/A/; $x} ); $obj->stripSignature(OPTIONS) Strip the signature from the body. The body must already be decoded otherwise the wrong lines may get stripped. Returned is the stripped version body, and in list context also the signature, encapsulated in its own body object. The signature separator is the first line of the returned signature body. The signature is added by the sender to tell about him- or herself. It is superfluous in some situations, for instance if you want to create a reply to the person's message you do not need to include that signature. If the body had no signature, the original body object is returned, and "undef" for the signature body. -Option --Default max_lines 10 pattern qr/^--s?$/ result_type <same as current> max_lines => INTEGER|undef The maximum number of lines which can be the length of a signature. Specify "undef" to remove the limit. pattern => REGEX|STRING|CODE Which pattern defines the line which indicates the separator between the message and the signature. In case of a STRING, this is matched to the beginning of the line, and REGEX is a full regular expression. In case of CODE, each line (from last to front) is passed to the specified subroutine as first argument. The subroutine must return TRUE when the separator is found. result_type => CLASS The type of body to be created for the stripped body (and maybe also to contain the stripped signature) example: my $start = $message->decoded; my $start = $body->decoded; my $stripped = $start->stripSignature; my ($stripped, $sign) = $start->stripSignature (max_lines => 5, pattern => '-*-*-'); SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/ LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2012-05-07 Mail::Message::Body::Construct(3pm)
All times are GMT -4. The time now is 12:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy