LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bashrc and .bash_profile (https://www.linuxquestions.org/questions/programming-9/bashrc-and-bash_profile-374408/)

happy78 10-18-2005 04:38 PM

bashrc and .bash_profile
 
hi all,

I have a bash script. It is running by a group of users; and they have a special .bash_profile and .bashrc.

How do I include .bash_profile and .bashrc in my script, so that when others run it, it should be able to find all commands and alias inside those bash files

Thank you for your time and help.

happy78 10-18-2005 05:01 PM

and the error code when they run my script is 127

primo 10-18-2005 10:47 PM

See your own ~/.bashrc to see how it sources /etc/bashrc

The with ~/.bash_profile

happy78 10-19-2005 01:44 PM

Hi Primo,

My .bash_profile is like this:

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

so I did a similar thing to my script by putting
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
inside it. But the problem still persists.

primo 10-19-2005 03:39 PM

From the bash manpage:
Quote:

If a command is not found, the child process created to execute it returns a status of 127.
Try adding "-x" to "#!/bin/sh" or "#!/bin/bash" to see where it fails. It should be like "#!/bin/sh -x"

happy78 10-19-2005 04:26 PM

I follow your instruction, and everything looks fine....no problem.
Oh, I forgot to mention that, I call this script from a java program.
Runtime.exec(bash);

and the bash file is like a wrapper that runs other script. If I was to run the bash file against those scripts directly w/o going through java, everything works fine. But If java calls the wrapper, then wrapper executes those script; the result is 127....and sometimes is 1.


All times are GMT -5. The time now is 11:51 AM.