Sponsored Content
Top Forums Shell Programming and Scripting Bad substitution error in shell script Post 302734793 by man4ish on Thursday 22nd of November 2012 10:08:15 PM
Old 11-22-2012
Bad substitution error in shell script

I have script data.sh which has following error.

Script Name : data.sh


Code:
#!/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:

./data.sh: 7: Bad substitution

May i know where i am wrong? How to fix this pblm?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bad substitution errors in shell script

Hello, I was hoping for a second pair of eyes or a little bit of help figuring out what my error is in a script. I did some searching in the forums and didn't find anything so please forgive me if it a similar problem has been discussed before. My script accepts normal user arguments; however,... (2 Replies)
Discussion started by: Jackinthemox
2 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

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... (5 Replies)
Discussion started by: adshocker
5 Replies

4. 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

5. 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

6. 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

7. Solaris

Get file name in shell scrip loop: bad substitution

Hi guys. Good day, morning, afternoon or night, depending on where you live. I have a script shell in which I am looping on files (absolute path) see code section above. I always have an error: bad substitution. :wall: Is it because my variable file is the index of the loop and not a normal... (4 Replies)
Discussion started by: soueric
4 Replies

8. 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

9. 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

10. 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
SAR2PCP(1)						       Performance Co-Pilot							SAR2PCP(1)

NAME
sar2pcp - Import sar data and create a PCP archive SYNOPSIS
sar2pcp infile outfile DESCRIPTION
sar2pcp is intended to read a binary System Activity Reporting (sar) data file as created by sadc(1) (infile) and translate this into a Performance Co-Pilot (PCP) archive with the basename outfile. However, if infile has the suffix ".xml", then it will be considered already in XML format and sar2pcp will operate directly on it. The resultant PCP achive may be used with all the PCP client tools to graph subsets of the data using pmchart(1), perform data reduction and reporting, filter with the PCP inference engine pmie(1), etc. A series of physical files will be created with the prefix outfile. These are outfile.0 (the performance data), outfile.meta (the metadata that describes the performance data) and outfile.index (a temporal index to improve efficiency of replay operations for the archive). If any of these files exists already, then sar2pcp will not overwrite them and will exit with an error message of the form __pmLogNewFile: "blah.0" already exists, not over-written sar2pcp is a Perl script that uses the PCP::LogImport Perl wrapper around the PCP libpcp_import library, and as such could be used as an example to develop new tools to import other types of performance data and create PCP archives. A Python wrapper module is also available. CAVEATS
When not using the XML input option, sar2pcp requires infile to have been created by a version of sadc(1) from <http://sebastien.godard.pagesperso-orange.fr/> which includes the sadf(1) utility to translate infile into an XML stream (any since version 6); sar2pcp will automatically run sadf(1) and translate the resultant XML into a PCP archive. When using binary sadc files it is important to ensure the installed sadf is compatible with the version of sadc that originally generated the binary files. Simply assuming a newer installed version will work is unfortunately far too optimistic, and nor should one assume that binary data from different platforms (e.g. different endianness) will work - these issues are due to limitations in sadc and sadf, and not in sar2pcp itself. Fortunately, the sadf message indicating that an incompatibility has been detected is consistent across versions, and is always prefixed Invalid system activity file Using an XML infile has the advantage that the installed version of sadf is completely bypassed. sar2pcp undertakes to transform any valid XML produced by any of the different variations of sadf into a valid PCP archive. Any version of PCP will be able to interpret the archive files produced by any version of sar2pcp, and you are also free to move the binary PCP archive between different platforms, different hardware, even different operating systems - it Just Works (TM). SEE ALSO
pmie(1), pmchart(1), pmlogger(1), pmlogextract(1), pmlogsummary(1), sadc(1), sadf(1), sar(1), Date::Parse(3pm), Date::Format(3pm), PCP::LogImport(3pm), XML::TokeParser(3pm) and LOGIMPORT(3). 3.8.10 Performance Co-Pilot SAR2PCP(1)
All times are GMT -4. The time now is 12:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy