rm:command not found in linux Bash shell script

Hi All,

Linux lxs3er06 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:58:04 EST 2007 i686 i686 i386 GNU/Linux

Issue:

While executing shell scripts in bash shell, following error messages are thrown:

rm:command not found 

On doing little investigation, I added '/bin' to $PATH and on doing echo $PATH

/bin is shown in $PATH but still the issue exists.

But on adding /bin/rm shell script now works fine without any issues.

But it doesn't work fine without adding /bin/rm as above.

Please advise as to how could we resolve this issue.

Thanks for your time!

Regards,

The running shell will not pick new modified $PATH.
export $PATH and then run script.
OR run script in a new shell/terminal.

Please provide output of

 echo $PATH 

If possible part of script too.

Also as quick solution. u can source your home dir .bashrc and .profile file in your script.

. /home/usr/.bashrc 
. /home/usr/.profile 

This way u will have all your alias / PATH available for script.

I am getting the following error while doing export $PATH

export $PATH
-bash: export: `/data/R12VIS/apps/tech_st/10.1.3/perl/bin:/data/R12VIS/apps/tech_st/10.1.2/bin:/data/R12VIS/apps/apps_st/appl/fnd/12.0.0/bin:
/data/R12VIS/apps/apps_st/appl/ad/12.0.0/bin:/data/R12VIS/apps/tech_st/10.1.3/appsutil/jdk/jre/bin:
/data/R12VIS/apps/apps_st/comn/util/unzip/unzip::/data/R12VIS/apps/tech_st/10.1.2/bin:/usr/bin:/usr/ccs/bin:/usr/sbin:
/data/R12VIS/apps/tech_st/10.1.3/perl/bin:/data/R12VIS/apps/tech_st/10.1.2/bin:/bin:/data/R12VIS/apps/tech_st/10.1.3/appsutil/jdk/jre/bin:
/data/R12VIS/apps/apps_st/comn/util/unzip/unzip:/data/R12VIS/apps/tech_st/10.1.2/bin:/usr/bin:/usr/ccs/bin:/usr/sbin:/usr/kerberos/bin:
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/data/R12VIS/apps/tech_st/10.1.3/appsutil/jdk/bin:/bin:/home/applmgr/bin:
/data/R12VIS/apps/tech_st/10.1.3/appsutil/jdk/bin:/bin:/home/applmgr/bin': not a valid identifier

Regards,

---------- Post updated at 02:37 PM ---------- Previous update was at 02:33 PM ----------

.bash_profile of the user 'abc':

. /data/R12VIS/apps/apps_st/appl/APPSVIS_lxs3er06.env

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

export PATH=$PATH:$HOME/bin

unset USERNAME
export SCRIPTS=/data/R12VIS/scripts
export DISPLAY=lxs3er06.solutions.glbsnet.com:0

---------- Post updated at 02:39 PM ---------- Previous update was at 02:37 PM ----------

Here's the script:

-bash-3.00$ cat XX_AOL_GEN_SCRIPT_RAMN.prog
#!/bin/bash


echo "Actual Parameter : "$*
export $FCP_LOGIN=`echo $* | cut -d " " -f1 | cut -d "=" -f2 | sed 's/"//g'`
echo "FCP_LOGIN : "$FCP_LOGIN
export $EXECUTE=`echo $* | cut -d " " -f5 | sed 's/"//g'`
echo "EXECUTE : "$EXECUTE
export $PATH=`echo $* | cut -d " " -f6 | sed 's/"//g'`
echo "PATH : "$PATH
cd $PATH
pwd
cd $PATH
rm -rf Concurrent_Program
mkdir Concurrent_Program
chmod 777 Concurrent_Program
cd Concurrent_Program
echo "Something to check On" > outputfile.txt1
-bash-3.00$

You don't need to re-export the PATH if it is already exported:

> mkdir T1 && echo echo Hello > T1/Echo1 && chmod u+x T1/Echo1
/tmp/test1 > PATH=$PATH:T1
/tmp/test1 > Echo1
Hello

Please show the value of PATH, as mtomar suggests.

edit: You updated your post, see vbe's comments...

How did you load the path variable?

export $PATH
-bash: export: `/data/R12VIS/apps/tech_st/10.1.3/perl/bin:/........:/bin:/home/applmgr/bin': not a valid identifier

What I put in red has nothing to do with PATH...

Value of PATH:

-bash-3.00$ echo $PATH
/data/R12VIS/apps/tech_st/10.1.3/perl/bin:/data/R12VIS/apps/tech_st/10.1.2/bin:/data/R12VIS/apps/apps_st/appl/fnd/12.0.0/bin:/data/R12VIS/apps/apps_st/appl/ad/12.0.0/bin:/data/R12VIS/apps/tech_st/10.1.3/appsutil/jdk/jre/bin:/data/R12VIS/apps/apps_st/comn/util/unzip/unzip::/data/R12VIS/apps/tech_st/10.1.2/bin:/usr/bin:/usr/ccs/bin:/usr/sbin:/data/R12VIS/apps/tech_st/10.1.3/perl/bin:/data/R12VIS/apps/tech_st/10.1.2/bin:/data/R12VIS/apps/tech_st/10.1.3/appsutil/jdk/jre/bin:/data/R12VIS/apps/apps_st/comn/util/unzip/unzip:/data/R12VIS/apps/tech_st/10.1.2/bin:/usr/bin:/usr/ccs/bin:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/data/R12VIS/apps/tech_st/10.1.3/appsutil/jdk/bin:/bin:/data/R12VIS/apps/tech_st/10.1.3/appsutil/jdk/bin:/bin:/home/r10user/bin
-bash-3.00$

My Friend, What is all exports in script. I think what you want to do is following

FCP_LOGIN=`echo $* | cut -d " " -f1 | cut -d "=" -f2 | sed 's/"//g'`
echo "FCP_LOGIN : "$FCP_LOGIN
EXECUTE=`echo $* | cut -d " " -f5 | sed 's/"//g'`
echo "EXECUTE : "$EXECUTE

Also Change PATH in your script to MYPATH or DIRPATH.
Since you are using PATH it overwrites env PATH and ur script complains that command not found.

Thank You All for your time.

The issue is now resolved.

Regards,

Am I misreading this or is this a wrong type of quote (just after export) ?

Please post the original code if it is not just a matter of correcting the quote.