LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-28-2012, 06:31 AM   #16
ravi_nandula
Member
 
Registered: Sep 2011
Posts: 81

Original Poster
Rep: Reputation: Disabled
Thumbs up


Quote:
Originally Posted by devUnix View Post
Ravi, you need bash Beginner's Guide or Advanced Bash Scripting Guide found on www.tldp.org

To run anything at log-in, edit your .bash_profile file found your home directory (the one that you are placed in when you log-in to your Unix/Linux system). Check it by issuing this command:

Code:
ls -ld .*
or


Code:
ls -la
You should see files ending in "profile" beginning with ".". It could be .profile or .bash_profile or .sh_profile. Usually, it is your "profile" file that is executed whenever your log-in to your system. Similarly there is a .logout file whose function should be obvious now.

So, add this line at the end of your .profile file:

Code:
echo "Hello, ${USER}!"


and add these lines at the end of your .logout file:

Code:
echo "Bye, ${USER}!"
read -p "Press enter to log out..."
You can actually do more than that. Just keep your codes in a separate script file and then call it from within any of the above files:


Code:
./myScript.sh
A Note on the Variable: We enclose the variable's name with curly braces in case any other character or word is adjacent to it so that it is separately taken as a variable and not as a part of the other word. In the above case, we have separated the variable's name from the exclamation mark.

To check your home directory issue this command at the Command Prompt / Shell Prompt:

Code:
echo $HOME
To directly get into your home directory, do this:

Code:
cd
Yes, no argument is supplied this time. $HOME is taken by default.
--------------------------------------------
Hey devunix,

thanks for helping ...and now I am able to print a msg whenever I login n logout.
And also i feel the website also helpful for me.........
 
Old 03-28-2012, 06:44 AM   #17
ravi_nandula
Member
 
Registered: Sep 2011
Posts: 81

Original Poster
Rep: Reputation: Disabled
hey DevUnix,

Just now I got a doubt that .......in the starting for the script we write....
#!/bin/bash

what is the use of it...........only to mention that it is bash script ?????????
 
Old 03-28-2012, 07:00 AM   #18
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Maybe you missed post #10 in this thread. Please (re-)read.
 
  


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
[SOLVED] what is the meaning $$ in shell procfs Linux - Newbie 3 01-14-2011 12:25 AM
How to ssh from a shell script ? For ppl who can write shell scripts. thefountainhead100 Programming 14 10-22-2008 07:24 AM
meaning of if [ -z $SOMETHING....] in bash shell darwinianlo Linux - Newbie 8 08-09-2007 12:02 PM
what is the meaning of editor & scripts Fuzia Linux - Newbie 5 04-06-2006 08:02 AM
'./file' meaning in python & shell script Chowroc Programming 7 12-30-2005 03:32 AM


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