Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Coundown Feature to /etc/motd file

Status
Not open for further replies.

ttyguy

IS-IT--Management
Jan 8, 2003
15
US
Is there a way to add a countdown script file to the /etc/motd file? I would like to add this to show users how many days until (?) as they log in.

Thanks in advance..

ttyguy
 
Until what? You could just set something up to generate a new motd file everyday with the new value. That would be the easiest solution.
 
Thanks for the reply...

The day I have in mind is the day after Christmas. This is a big day in retail. How could I generate this script? Any ideas?
[americanflag]
 
Well, there are two ways you can do this....

1)

Put this script in the crontab and set it to run everyday.
Something like this:

#!/usr/bin/ksh -p

# Check for leap year.
cal 2 `date "+%Y"`|grep 29 1> /dev/null 2>&1
if [ $? -eq 0 ]
then
DAYS=366
else
DAYS=365
fi

# Get ANS here.
let ANS=${DAYS}-`date "+%j"`
echo "Days till Dec. 26th: ${ANS}\n" > /etc/motd

# Add whatever else goes here, such as a standard message.

cat STANDARD_MESSAGE >> /etc/motd

That should work or something similar...the following could also be done...

2)

Edit /etc/skel/.profile to include the above entry to get the number of days till Dec. 26th and then just copy the .profile scheme to all of the home directories.

Add this after the message:

echo "Days till Dec. 26th: ${ANS}\n"
read PAWS?"Press [Enter] to continue."
clear


Either one of these solutions could work depending on your setup.
 
This year boxing day, December 26th, is the 360th day of the year.

So you could add the following lines to the /etc/profile just after it does the cat /etc/motd:

[tt]DAYNUM=`date +%j`
echo `expr 360 - $DAYNUM` days until boxing day[/tt]
Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top