Personalizing UNIX login script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Personalizing UNIX login script
# 1  
Old 06-14-2006
Personalizing UNIX login script

Hi all,

I am just starting to learn UNIX and I have a question that I hope that you can assist me with.

I want to create a comment with my login script that will respond to each user personally. Based on the time that they are logging in.

I want it to say, Good Morning and such

Any suggestions on a good place to start?

Thanks in advance.
# 2  
Old 06-14-2006
You will have to grep for the username in /etc/passwd, then get the Person's name as it is entered in that file.

Code:
#!/bin/ksh
username=`logname`
fullname=$(grep "$username" /etc/passwd| awk '{print $5}' )
echo "Good day, $fullname"

# 3  
Old 06-14-2006
The FS may need to be set in the awk statement
Code:
#!/bin/ksh
username=`logname`
fullname=$(grep "$username" /etc/passwd| awk -F: '{print $5}' )
echo "Good day, $fullname"

# 4  
Old 06-14-2006
Code:
#!/bin/ksh

echo "Good day, $(nawk -F: -v user=$(logname) '$1 == user {print $5}' /etc/passwd)"

# 5  
Old 06-14-2006
And,
Code:
when ="evening"
date +%r| grep -q 'PM'
if [ $? -eq 0 ] ; then
   when="morning"
fi
echo "Good $when, $fullname"

# 6  
Old 06-15-2006
or
Code:
#!/bin/ksh

hour=`date | cut -c12-13`
case ${hour} in
 @(0[0-9]|1[1-2]) )       when='Morning' ;;
 @(1[3-7]) )                 when='Afternoon' ;;
              *)                 when='Evening' ;;
esac

echo "Good $when, $fullname"

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Remote login UNIX box from java passing parameters to the custom script called in the profile

Hello Good Day / Guten Tag.... I have to login the server and the user profile contains some scripts which need the inputs to be taken from the keyboard. So I use the method to conn.authenticateWithKeyboardInteractive(username, new InteractiveCallback() { public String... (1 Reply)
Discussion started by: Sanalkumaran
1 Replies

2. Shell Programming and Scripting

Script as login shell (passing args to login shell)

Hello all, for security reasons my compagny imposes that my script be launch remotly via ssh under the users login shell. So serverA launches the ssh command to serverB which has a local user with my script as a login shell. Local script works like a charm on his own. serverB$ grep... (20 Replies)
Discussion started by: maverick72
20 Replies

3. Shell Programming and Scripting

Issues for script that login to a unix box

Hi, I have a script that should login to a different box then the box that i am in and run the commands. I have the script sample below that logins to a unix box and get the files .Looks like ls-lrt command is not running or its wrongly used. #!/bin/bash # Ask the user for build month... (5 Replies)
Discussion started by: learninguser235
5 Replies

4. Shell Programming and Scripting

Help with Unix bash shell script login

Hi, I am a complete Unix novice and need some help with creating a login shell script. I have created a file with user details i.e. PIN, name etc and require help in recalling the specified details from the file and being prompted for a password on login. Any help would be very much appreciated.... (0 Replies)
Discussion started by: tdsrogers
0 Replies

5. Shell Programming and Scripting

UNIX Script to query Active Directory: give cn (NT login name) and receive mail (Email address)

Hi folks I need to write UNIX script (with ldapsearch) to query Active Directory. Input is NT login name and output is Email address. Attached a screenshot of Sysinternals "AD Explorer". I need to do the same in CLI. http://i.imgur.com/4s6FB.png I am absolute LDAP/ldapsearch noob. (0 Replies)
Discussion started by: slashdotweenie
0 Replies

6. Shell Programming and Scripting

Shell script in tracking both the passed and failed login in a unix server

Can you help me in providing the following output or a quite similar to this from a shell script ? *** Logins Summary Information ***** ---------------------------------- Failed Login Attempts for Invalid Accounts Date Time IP-ADD Account ... (0 Replies)
Discussion started by: linuxgeek
0 Replies

7. Web Development

Login in Unix

Can anyone plz share the HTML code for login in UNIX. I am not able to verify the password. (2 Replies)
Discussion started by: manish.s
2 Replies

8. Programming

Login script for unix ?

Anyone know of a script or program in a unix platform that will allow one login and password for three databases ? Say i have a social site that has a video site and phpBB3 forum but i want them connected as one login. I heard there is a script that does that , anyone know the name or where to get... (0 Replies)
Discussion started by: rumrunner439
0 Replies

9. UNIX for Advanced & Expert Users

UNIX login ID

Hello World: I need to have a user ID called devapp in the passwd and shadow file for a certain application to start. The problem is that I do not want users to be able to use the devapp login ID to log directly into the system. The users sometimes need to start and stop the... (3 Replies)
Discussion started by: rambo15
3 Replies

10. UNIX for Dummies Questions & Answers

personalizing my unix environment

I share a login id/password with several folks so I don't like to change the .profile or other environment variables (e. g., set ignorecase in vi) that other users may expect to be set. Any suggestions to tailor my environment that will not affect other users (2 Replies)
Discussion started by: artjaniger
2 Replies
Login or Register to Ask a Question