LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-18-2005, 05:38 PM   #1
happy78
Member
 
Registered: Aug 2003
Posts: 50

Rep: Reputation: 15
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.
 
Old 10-18-2005, 06:01 PM   #2
happy78
Member
 
Registered: Aug 2003
Posts: 50

Original Poster
Rep: Reputation: 15
and the error code when they run my script is 127
 
Old 10-18-2005, 11:47 PM   #3
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
See your own ~/.bashrc to see how it sources /etc/bashrc

The with ~/.bash_profile
 
Old 10-19-2005, 02:44 PM   #4
happy78
Member
 
Registered: Aug 2003
Posts: 50

Original Poster
Rep: Reputation: 15
Unhappy

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.
 
Old 10-19-2005, 04:39 PM   #5
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
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"
 
Old 10-19-2005, 05:26 PM   #6
happy78
Member
 
Registered: Aug 2003
Posts: 50

Original Poster
Rep: Reputation: 15
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bashrc vs. bash_profile mikeshn Linux - General 9 02-10-2008 02:46 PM
.bashrc .bash_profile Soulful93 Slackware 4 05-03-2005 04:02 AM
~/.bashrc, ~/.bash_profile Sinope Linux - Newbie 6 08-17-2004 03:40 AM
.bashrc or .bash_profile? statmobile Linux - Newbie 1 02-04-2004 10:08 PM
.bashrc vs .bash_profile xor3 Linux - Newbie 1 08-16-2003 01:52 PM


All times are GMT -5. The time now is 10:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration