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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
05-25-2003, 10:58 AM
|
#1
|
LQ Newbie
Registered: May 2003
Posts: 20
Rep:
|
login message shell script?
I am a newbie to the Linux world, and I need to make a shell script that will display "Welcome (username), today is (date), and it is now (time)"
I went and bought 3 books, with not much help there, and did search after search, and can't figure it out. Please Help!
thanks
jczr2
|
|
|
05-25-2003, 11:11 AM
|
#2
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
How about this?
Code:
#!/bin/bash
DATE=`date +"Today is %A %D, and it is now %R"`;
echo Welcome $USER. $DATE
|
|
|
05-25-2003, 11:12 AM
|
#3
|
LQ Newbie
Registered: May 2003
Posts: 20
Original Poster
Rep:
|
i have been trying it sort of like that, but where do i save it and what extension do i save it as?
thanks
|
|
|
05-25-2003, 11:17 AM
|
#4
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
Just put the last 2 lines of the code at the end of each users ~/.bash_profile script. Or probably better is to save the above code into a file called "/bin/welcome.sh", chmod the file 755 and then you just need to put "welcome.sh" at the bottom of the users .bash_profile files. This also gives you the option to change it for all users in one place.
If you want to make it the default for new users then put the per user code at the bottom of:
/etc/skel/.bash_profile
|
|
|
05-25-2003, 11:28 AM
|
#5
|
LQ Newbie
Registered: May 2003
Posts: 20
Original Poster
Rep:
|
i am way confused, i understand the script, but there are 15 users and how do i use pico to edit thst snd add those lines of code to it. I just started learning linux 1 month ago, so i'm not too great with it.
thanks
|
|
|
05-25-2003, 11:28 AM
|
#6
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
you should add it to /etc/bashrc, not to everyones own bashrc.
|
|
|
05-25-2003, 11:35 AM
|
#7
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
Quote:
Originally posted by acid_kewpie
you should add it to /etc/bashrc, not to everyones own bashrc.
|
Good point but only if you want it to run for all users.
As a side note you could also shorten the code I suggested earlier.
Code:
date +"Welcome $USER. Today is %A %D, and it is now %R";
Last edited by david_ross; 05-25-2003 at 11:40 AM.
|
|
|
05-25-2003, 11:36 AM
|
#8
|
LQ Newbie
Registered: May 2003
Posts: 20
Original Poster
Rep:
|
i will try that, but i want it to say welcome to each username, not a gereric for each one.'
thanks
|
|
|
05-25-2003, 11:40 AM
|
#9
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
The $USER will pull the username that you are logged in as so you can put it in /etc/bashrc like acid_kewpie said if you want.
|
|
|
05-25-2003, 11:42 AM
|
#10
|
LQ Newbie
Registered: May 2003
Posts: 20
Original Poster
Rep:
|
ok, i added the shortened line to the end of the /etc/bashrc in pico, and logged out and back in , and nothing came up.
|
|
|
05-25-2003, 11:47 AM
|
#11
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
are you using bash? show us what the last few lines of bashrc are.
|
|
|
05-25-2003, 11:47 AM
|
#12
|
LQ Newbie
Registered: May 2003
Posts: 20
Original Poster
Rep:
|
when i open the terminal window, it says welcome root. date +"Today is %A %D, and it is now %R"
at the top of the window. I was hoping to get it on the gui when it starts up
|
|
|
05-25-2003, 11:49 AM
|
#13
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
on what gui??
|
|
|
05-25-2003, 11:50 AM
|
#14
|
LQ Newbie
Registered: May 2003
Posts: 20
Original Poster
Rep:
|
at the terminal, i typed pico /etc/bashrc and a long script came up, and the last line before i added one says : # vim:4:sw=4
|
|
|
05-25-2003, 11:51 AM
|
#15
|
LQ Newbie
Registered: May 2003
Posts: 20
Original Poster
Rep:
|
sorry, in the red hat 7.3 linux gui
|
|
|
All times are GMT -5. The time now is 12:24 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|