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

You need a space character after the full stop if you want environment variables created in the script to be available to the user.

. /home/user-name/test.sh

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

. ./test.sh

Many would prefer:

. ${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:

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

These should be equivalent:

/home/user-name/test.sh
${HOME}/test.sh
./test.sh

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

I'm wondering about the

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.

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

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.

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