![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Login Script | vinna | Shell Programming and Scripting | 3 | 05-06-2008 09:31 PM |
| login from a shell script????? | skyineyes | Shell Programming and Scripting | 2 | 07-16-2007 06:59 AM |
| How can we ssh login with script? | pcsaji | Shell Programming and Scripting | 5 | 03-27-2006 11:37 AM |
| Login script | newtoxinu | UNIX for Dummies Questions & Answers | 3 | 07-25-2005 05:50 PM |
| Script with SU Login | bkhviking | Shell Programming and Scripting | 3 | 06-18-2005 08:35 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help on a login script
I am trying to get a script together so when any user logs into the system it will display a message. After the user answers the question based on the answer they will proceed into the system or be logged out. I only want the person to get prompted once per message. Below is what I have in all the users .bash_profile
#!/bin/bash #set -x DATE=`date +"%Y/%m/%d %H:%M"` USER=`who am i | cut -c1-8` stty erase ^H clear echo "" echo " GT TCY Message of the Day" echo "" echo "**Are you familiar with the new docs on opsdoc website???" echo "" printf "Please enter Yes or No : " read ANSWER echo "" echo "" if [[ $ANSWER = "Yes" ]] || [[ $ANSWER = "YES" ]] || [[ $ANSWER = "yes" ]] then echo "Thanks, Have a good day..." exit 1 # read ANSWER echo "" echo "" else echo "Please review docs and come back later" sleep 3 skill -KILL -u $USER fi Any help would be greatly appreciated. Thanks Greg |
|
||||
|
If you are having a problem, it's usually a good idea to describe what happens and how you think it's wrong. The "exit" you have in the "have a good day" part will also exit the session, more elegantly than the kill. Just fall out of the conditional and it should work. Anyway, skill seems excessive (if they have another session open, won't it kill that one too?), and simply exiting also gets rid of the rather silly guessing of the user. (Hint: $LOGNAME should already be set to the current user, but let's not dwell on that.) It would seem like a good idea to include the URL for the documents you are referring to. The if is a bit ugly, case is often more elegant when it comes to pattern matching. Code:
case $ANSWER in [Yy][Ee][Ss] | [Yy]) echo "Thanks, have a good day";;
*) echo Please review docs and come back later"
sleep 3
exit;;
esac
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|