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
    Value next to PATH= made system not able to find chmod and find – Tagwint Jun 5 '18 at 18:10
  • 3
    I don't believe you that the first one "works". – glenn jackman Jun 5 '18 at 18:10
  • @glenn jackman, neither do I, unless $1 was defined to something reasoneable and was passed to the script – Tagwint Jun 5 '18 at 18:12
  • Both scripts cannot work. Well, they did partially work with bosh since bosh has a builtin find program based on libfind. – schily Jun 5 '18 at 18:15
  • A cheeky comment: it will work fine if you call it like ./bpc.sh ":$PATH" – glenn jackman Jun 5 '18 at 18:23
2

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.

  • I would like to say to all excuse me for this post. – Milton Andres Gomez Jun 6 '18 at 12:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.