Problem in .bash_profile Linux


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in .bash_profile Linux
# 1  
Old 11-04-2009
Problem in .bash_profile Linux

Hello Friends,

I was trying to give a text/welcome message to a specific user just after his login.
For that i had added a echo test message line in .bash_profile of that user.

Which is not working ....


Also i had to execute a script on his login
for that i had tried to enter the script name (./home/user-name/test.sh)
in the .bash_profile (also tried to enter teh same in .bashrc)

permission of file is set to 777

Can some one please help me in this
# 2  
Old 11-04-2009
You need a space character after the full stop if you want environment variables created in the script to be available to the user.

Code:
. /home/user-name/test.sh

Or if the script is in the user's home directory you can use a relative path:

Code:
. ./test.sh

Many would prefer:

Code:
. ${HOME}/test.sh

If the objective is not to make environment variables available to the user but just to execute the script, you don't want the full stop at all because it is interpreted as a directory name and the script will be searched for in:
Code:
/home/user-name/home/user-name/test.sh.

These should be equivalent:
Code:
/home/user-name/test.sh
${HOME}/test.sh
./test.sh


Last edited by methyl; 11-04-2009 at 10:08 AM..
# 3  
Old 11-04-2009
Java

Many thank for your reply.

we had tried with that too.

while executing . /home/user-name/.bash_profile
then the script is executing without any issue but the nevironment variable under the .bash_profile was not exported.

we had also tried to add . /home/user-name/.bash_profile at teh end of .bashrc file.
STill that is not working
# 4  
Old 11-04-2009
I'm wondering about the

Quote:
For that i had added a echo test message line in .bash_profile of that user.

Which is not working ...
Is it possible that you have an exec line above where you added the echo?

Or (which could also explain the failing of the other script) - is it possible that this user is NOT using Bash? If he is using another shell, nothing in .bash_profile is going to work.

And just to cover all the bases - he might not have a shell at all. Sometimes users are set (in /etc/passwd) to directly execute a particular program. This isn't common, but if the system wassetup by someone else, it's certainly possible.

Last edited by TonyLawrence; 11-04-2009 at 10:19 AM.. Reason: Additional thought
# 5  
Old 11-04-2009
We had below code in our .bash_profile
:

in the starting of teh script we are just calling teh .bashrc script in the same directory

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

then we are exporting some of teh variables which are also not working.

Part of .bash_profile

TEST="testing" ; export TEST

and after login when we do echo $TEST that is returning a blank

---------- Post updated at 07:53 PM ---------- Previous update was at 07:51 PM ----------

so how can we check that if the user is not having a shell ?

Note: we are able to execute the other scripts after login.
Even we are able to execute the . .bash_profile

---------- Post updated at 08:04 PM ---------- Previous update was at 07:53 PM ----------

or if tehre is any other way to provide a welcome/information message to the user then please share that
# 6  
Old 11-09-2009
I'd check that his /etc/passwd entry calls /bin/bash and that his home directory actually is where you are editing the .bash_profile and that the directory itself has proper perms for him.

If that's all fine, I'd look to see if he owns his .bash_profile.
# 7  
Old 11-13-2009
Below is the users Home directory view in home directory:

drwxrwxrwx 3 user tddev 4096 Nov 12 08:14 user

.bash profile view:

$ ls -ltr .bash_profile
-rwxr-xr-x 1 user tddev 706 Nov 9 08:24 .bash_profile
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Renaming .bash_profile to .profile

Hi Gurus, Recently we have migrated our servers from AIX to Linux. Most of the scripts written in AIX server are sourcing environment variables using .profile file. Now we have the following options: 1. Change all the scripts where ever .profile is being used and replace it with... (14 Replies)
Discussion started by: svajhala
14 Replies

2. UNIX for Dummies Questions & Answers

.bash_profile question

Hello everyone, I'm trying to set my .bash_profile to change my primary prompt from this: banbatchtest1v:MCPPRD:~>to this: banbatchtest1v:MCPPRD:/home/rcarvall> Here's what my .bash_profile looks like right now: # .bash_profile # Get the aliases and functions if ; then .... (2 Replies)
Discussion started by: galileo1
2 Replies

3. UNIX for Dummies Questions & Answers

Bash_profile versus bashrc

Hi All Please can you tell , what is the difference between bash_profile and bashrc. How to create them? (8 Replies)
Discussion started by: fretagi
8 Replies

4. Shell Programming and Scripting

Is there a way to organize bash_profile across different platforms

I want to have one .bash_profile works on multiple platform, ubuntu, debian, redhat, cygwin, osx. So how should I organize .bash_profile? It can be multiple files in some subdir Let me brief you: what i want is a way to organize bash_profile across platforms so I can use one set of profiles... (2 Replies)
Discussion started by: John_Peter
2 Replies

5. Red Hat

.bash_profile file corrupted

Hi, Unexpectedly i entered wrong entries in .bash_profile for my user which has administrative permissions. So, i am getting errors for every command. I dont have backup file also, so any body can help me how to recover it. Regards, Mastan (7 Replies)
Discussion started by: mastansaheb
7 Replies

6. UNIX for Advanced & Expert Users

bash_profile or .profile

Hi, happy new year. on AIX 6.1 , for user oracle , there are two files : bash_profile and .profile I do not know which one is executed when login ? How to know , More over in both of them we have : in .profile : ORACLE_HOME=/appli/oracle/product/10.2.0/db_1... (5 Replies)
Discussion started by: big123456
5 Replies

7. UNIX for Dummies Questions & Answers

bash_profile does not working

Hi all. when i connect as user megaguru i have a problem my .bash_profile does not working^:( if i do: . ./.bash_profile all enviroment variables are in place. How can i force linux to use .bash_profile before logon process? thanx in advance. (1 Reply)
Discussion started by: smallman
1 Replies

8. Shell Programming and Scripting

question in .bash_profile

We are more users using the oracle account, and people want to include theyr own files in .bash_profile. Like this: while ; do echo -n "LOGNAME is '$LOGNAME' (no sens), who are you? " >/dev/stderr read ln export LOGNAME=$ln done This works well when logging in to... (1 Reply)
Discussion started by: hannem
1 Replies

9. Shell Programming and Scripting

.bash_profile problem

Hi Guys, I modified my .bash_profile script , and tried to change the prompt. Following is the line of code in my .bash_profile script. export PS1=" \W " But I get the output as: \W This appears to be my prompt now. Any idea what should be done.. Thanks! (0 Replies)
Discussion started by: nua7
0 Replies

10. UNIX for Dummies Questions & Answers

numbers on permanently through .bash_profile

Hi Can anyone tell me if it is at all possible to edit ones .bash_profile, to make the setting on of line numbers (in vi/vim), permanent? I've been to a few IRC channels and people keep telling me it is more of a vi/vim thing and to use something called ".vimrc", however I heard that it is... (3 Replies)
Discussion started by: zorrokan
3 Replies
Login or Register to Ask a Question