0

I did write two scripts, where one has part simple code of the other ones and several comments in:

user : oracle both files are of oracle. both files have the execution clearance on : chmod +x fpc.sh && chmod +x bpc.sh

script that works: fpc.sh

#!/bin/bash
#
# author bla bla bla
#
ORACLE_SID=MyOracleSid
PATH=/app/oracle/admin/DB/$1
TARGHET="\/app\/oracle\/admin\/DB\/$1"
chmod -R 755 $PATH

find $PATH -type f -exec egrep 'ORACLE_SID' {} \; -print

script that doesn't works: bpc.sh

#!/bin/bash
#
# author bla bla bla
#
ORACLE_SID=MyOracleSid
PATH=/app/oracle/admin/DB/$1
#
#TARGHET="\/app\/oracle\/admin\/DB\/$1"
#
#
#
#
#
#
#
#
#
#
#
#
#
#
chmod -R 755 $PATH

find $PATH -type f -exec egrep 'ORACLE_SID' {} \; -print

bpc.sh gets:

chmod command not found find command not found

How is possible?

thanks for your collaboration,

1 Answers1

1

This is why using CAPS for variable names in Bash is a really bad idea.

If you had used snake_case or CamelCase, you would not have altered the environmental variable PATH.

Ergo:

path=/app/oracle/admin/DB/$1

is ok

PATH=/app/oracle/admin/DB/$1

is not.

Run

( set -o posix ; set )

to see just ow many variables you can mistakingly override with CAPS variables. Instead of trying to keep track of them, just take it as a general rule to not use CAPS.