The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-10-2008
gbarnes gbarnes is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 5
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
  #2 (permalink)  
Old 04-10-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0