Bad substituion error : Dont understand why


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Bad substituion error : Dont understand why
# 1  
Old 11-03-2016
Bad substituion error : Dont understand why

Hi Folks -

I'm getting the following error message when executing my script:

Code:
[oracle@exalytics-madc-01 Batch]$ chmod +x Winexe_Admin.sh
[oracle@exalytics-madc-01 Batch]$ ./Winexe_Admin.sh
Script Name: Winexe_Admin.sh
Script Name without EXT: Winexe_Admin
./Winexe_Admin.sh: line 43: ${_MAINPATH}${_LOGPATH}${LOGPATH$}${_YEAR}_${_MONTH}${_DAY}: bad substitution
mkdir: missing operand
Try `mkdir --help' for more information.

My script is as follows:

Code:
#!/bin/bash
#:: ------------------------------------------------------------------------
#::-- Script Name: .sh
#::  
#::-- Description: 
#:: 
#::-- Parameters:  Call properties file to get environment variables to determine 
#::                login info, database, application, etc.
#::        
#::-- Author:       
#::-- Date:           10/22/16
#:: ------------------------------------------------------------------------
#source /app/hyp_app/scripts/setenv.sh

#::-- Set Script Name --::
_SN=${0##*/}

echo "Script Name: $_SN"
echo "Script Name without EXT: ${_SN%%.sh*}"

#::-- Set Path Variables --::
_MAINPATH=/u01/Hyperion_Batch/
_LOGPATH=Logs/
_ERRORPATH=Errors/

#::-- Set Log & Error subdirectory pertaining to specific process --::

_PLOGPATH=LCM_Logs/
_PERRORPATH=LCM_Errors/

#::-- Set Date and Time Variable --::
_DAY=$(date +%d)
_MONTH=$(date +%m)
_YEAR=$(date +%Y)
_DATESTAMP=${_YEAR}${_MONTH}${_DAY}
_HOUR=$(date +%H)
_MINUTE=$(date +%M)
_SECOND=$(date +%S)
_TIME=${_HOUR}${_MINUTE}
_DATETIMESTAMP=${_DATESTAMP}_${_TIME}

#::-- Establish Log and Error File Directories --::
_ARC_LF=${_MAINPATH}${_LOGPATH}${LOGPATH$}${_YEAR}_${_MONTH}${_DAY}
_ARC_EF=${_MAINPATH}${_ERRORPATH}${_PERRORPATH}${_YEAR}_${_MONTH}${_DAY}
    mkdir -p ${_ARC_LF}
    mkdir -p ${_ARC_EF}

#::-- Prepare File Name Format --::    
_FN=${_TIME}_${_SN%%.sh*}

#::-- Establish standard out and standard error --:: 
_LF=${_ARC_LF}/${_FN}.log
_EF=${_ARC_EF}/${_FN}.err

#::-- Establish LCM Specifics --::

#::-- Set Process Variables --::#
_WINEXE_PATH=/u01/Hyperion_Batch/Scripts/Utilities/Winexe/winexe-1.00/source4/bin/


exec 2>${_EF} > ${_LF}

#:: Begin Script Processing --::
echo ---------------------------------------------------------
echo "Begin ${_SN%%.sh*} Process at ${_TIME}"                           
echo                                                                                                        
echo "Execute Winexe Process on Windows Server"                                         
echo ---------------------------------------------------------

${_WINEXE_PATH}winexe -U ‘domain/username%password!' //server 'cmd.exe /c  C:\Hyperion_Batch\Scripts\batch\WinexeTest.cmd'

if [ $? -eq 0 ]
then
  echo ---------------------------------------------------------
  echo "Execute Winexe Process on Windows Server Successful"                           
  echo ---------------------------------------------------------
  #::-- If empty, delete YYYY_MMDD error file subdirectory --::
  trap "[ -s ${_EF} ] || rm -f ${_EF} ] && rmdir ${_ARC_EF}" EXIT 0
  
else
  echo ---------------------------------------------------------
  echo "Execute Winexe Process on Windows Server Unsuccessful"                      
  echo ---------------------------------------------------------
  fi
  exit 1

I thought at first it was interpreter but I confirm its correct. Thanks for any input!!
# 2  
Old 11-03-2016
I think it doesn't like the LOGPATH$, so _ARC_LF is assigned an empty string (if at all), and
Code:
mkdir -p ${_ARC_LF}

doesn't have anything to work upon.
# 3  
Old 11-03-2016
Oh I see my issue - I didn't have the correct naming convention in there for the PLOGPATH & PERRORPATH variables. I'm stupid!

Thanks for the tip!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trying to understand perl error

I am trying to begin to troubleshoot this perl error that I keep getting, yet I get output is produced. The error is Use of uninitialized value in join or string line 175, <MANNO> line 7138 and below is line 175: I am not too sure what the error is but since not every line has an error on it, I... (1 Reply)
Discussion started by: cmccabe
1 Replies

2. Shell Programming and Scripting

Variable in awk substituion

I have a file with 20 blank spaces. I want to substitute each blank space for a string, and part of that string should include an incremental number Code while read line3 do awk -v var=${line3} '{i=var; sub("^]*$", "\\&\n@target G0.S"'$i'"\n@type xy"); print $0}'... (1 Reply)
Discussion started by: chrisjorg
1 Replies

3. UNIX for Dummies Questions & Answers

i dont know how to solve this error

can while do make aloop as do while in c language ? (1 Reply)
Discussion started by: teefa
1 Replies

4. Programming

Need help with this c++ source code! DOnt understand what some stuff mean.

Okay so I am just starting programming c++. I just started started to red "C++ for Dummies yesterday and theres a lot of things I do not understand from this book and this source code especially. I will first post the full source code and then post questions about certain thing, usually what they... (2 Replies)
Discussion started by: orszhak
2 Replies

5. Shell Programming and Scripting

I can't understand sed error output.

Hey forum, I have a problem with a script what used to work, but suddenly is not working anymore. I have been trying different things for an hour now and I give up :D . #!/bin/sh asukoht=`pwd` template=$1 for values in... (4 Replies)
Discussion started by: mario8eren
4 Replies

6. Solaris

bad substituion error

Dear All i am getting "bad substituion" error in the follwing piece of code when i run from crontab.however it works if i run directly from my machine. #!/bin/bash for i in `cat abc` do part1=${i:0:12} ; part2=${i:13:27} ; echo "$part1,$part2">> def done (1 Reply)
Discussion started by: asadlone
1 Replies

7. UNIX for Advanced & Expert Users

Tough Substituion command

I have lines like: Mg2.qns W=0.175u Mg2.qpsb W=0.175u Mg4.qns W=0.175u Mg4.qpsb W=0.175u Which I need to become: Mg2.qns W=wmg2qns Mg2.qpsb W=wmg2qpsb Mg4.qns W=wmg4qns Mg4.qpsb W=wmg4qpsb To acheive this individually line by line I use a command like:... (3 Replies)
Discussion started by: ggggdddd
3 Replies

8. Shell Programming and Scripting

Perl Arrays and Substituion

@xray =~ s/^ *//g; @xray =~ s/ *$//g; @xray =~ s/\s+/ /g; Guess I have a two part question ... First Is there a way to make substitutions, remove leading spaces, trailing spaces, and crunch multiple spaces into a single space, to the entire array, or must the substitutions be done on on... (1 Reply)
Discussion started by: popeye
1 Replies

9. Shell Programming and Scripting

Env Variable substituion in Sed (-s option)

Folks, I've been trying to use the ENV variable with slashes(/) in its value inside the sed substitution.. Sed 's/myval/'$MYVAL'/' file1 >> file.tmp If MYVAL=<sometext>, it works. if MYVAL=/home/venkat, it doesnt. *************************** bash-2.05$ export VAL=/home/venkat... (5 Replies)
Discussion started by: gvsreddy_539
5 Replies

10. What is on Your Mind?

dont understand

i'm trying to learn unix and i posted a question and what i was typing from school. i can't figure it out. how am i supposed to learn , when i get shutdown by an admin. for posting a homework question. doesn't make any sense. its a dumb rule. thanks for helping (4 Replies)
Discussion started by: AtomJ22
4 Replies
Login or Register to Ask a Question