LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 04: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, 05: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, 10: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, 01: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, 03: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, 04: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



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 01:46 PM
.bashrc .bash_profile Soulful93 Slackware 4 05-03-2005 03:02 AM
~/.bashrc, ~/.bash_profile Sinope Linux - Newbie 6 08-17-2004 02:40 AM
.bashrc or .bash_profile? statmobile Linux - Newbie 1 02-04-2004 09:08 PM
.bashrc vs .bash_profile xor3 Linux - Newbie 1 08-16-2003 12:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:44 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
Open Source Consulting | Domain Registration