Linux shell scripting using .profile to show customized welcome message to logged in users based on time
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
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.
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.
How to write a Shell Script to say Good Morning/Afternoon/Evening as you log on in the system?.
Read the "Question Guidelines" link in my posting signature. We're happy to help you with your scripts, but we will NOT write them for you. Post what you have written/done/tried on your own, and tell us where you're stuck.
Otherwise, there are THOUSANDS of easily-found bash scripting tutorials you can find with a brief Google search to get you started.
Hi,
Requirement is like this: while user logs into linux($ prompt), system will welcome him/her by saying good morning/good afternoon/good evening just before S prompt is shown. I have written a shell script welcome. It contains shell coding like now=`date +%H1 if test $now -le 12 then
echo "Good Morning, $LOGNAME" elif test now -le 16 then echo "Good Afternoon, $LOGNAME" else echo "Good Evening, $LOGNAME" fi. Now I want to place this sh welcome code into /home/.profile file for the required result. How to proceed? Pl suggest.
please use [code]here comes your script[/code] tags to keep formatting of your script. Otherwise it will be really hard to read/understand.
I do not really understand: what is your actual problem?
Hi,
Requirement is like this: while user logs into linux($ prompt), system will welcome him/her by saying good morning/good afternoon/good evening just before S prompt is shown. I have written a shell script welcome. It contains shell coding like now=`date +%H1 if test $now -le 12 then
echo "Good Morning, $LOGNAME" elif test now -le 16 then echo "Good Afternoon, $LOGNAME" else echo "Good Evening, $LOGNAME" fi. Now I want to place this sh welcome code into /home/.profile file for the required result. How to proceed? Pl suggest.
Again, you need to read the "Question Guidelines" link, and the LQ Rules...pay attention to the part about text-speak, and not using it, and about posting your code in CODE tags to make things easy to read.
And this post itself makes no sense...you just SAID "I want to place this sh welcome code into /home/.profile"....so DO IT. Open the file...insert the code...save and exit. Where is the difficulty?? And again, please show effort of your own; this is obviously a homework question, and doing even a small amount of research about the Linux login process would tell you what file(s) you need to look at, and give you examples. Your .profile and/or .bashrc are in the home directory for your user ID, like /home/user1/. If you want to apply this for the ENTIRE system, then you need to modify the system profile, in /etc.
telling us your requirements is not my definition of showing some effort.
but anyhow, i copy-pasted the script and formatted it a little:
Code:
#!/bin/sh
now=`date +%H1
if test $now -le 12
then
echo "Good Morning, $LOGNAME"
elif test now -le 16
then
echo "Good Afternoon, $LOGNAME"
else
echo "Good Evening, $LOGNAME"
fi
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.