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)
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:
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
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.
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.