Q: grab email username from script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Q: grab email username from script
# 1  
Old 04-26-2013
Q: grab email username from script

Hi all,

I want to set up a script to email a person to confirm another program is running but i wish to avoid having to customise the script for each individiual.

I am ok with what i need to do except i need to get the first and last name of the user to construct an email address to send to. The username variable and associated grep routines are not possible to use as they do not return anything. All i can get is the userid whch they log in with.

I feel the best way would be to grab the last and first names as set up in their email. Is there a way of using a script to return this info? I cannot assume they have sent or received emails either so i would need the info pulled from their settings

Thank you in advance for any assistance rendered.
# 2  
Old 04-26-2013
Have you tried anything so far?? Like a script for one defined user?
# 3  
Old 04-26-2013
Normally you would find first name last name in /etc/passwd, having the user login name or UID is enough to sort you out...
# 4  
Old 04-26-2013
Thanks for the reaponse Vbe. I did find code that dealt with this but alas it didnt work for me. I cannot recall the result due to trying a few things but i can say the result was either a blank or akin to a path/group descriptor than a persons name. I will redo it and gather the result again.

---------- Post updated at 09:37 PM ---------- Previous update was at 09:34 PM ----------

PikK45... i tried a few example scripts for milking the name based on userid but couldnt find anything to assist on the email side as yet.

I will redo my tests and post agan with what the results were for the non mail approach.
# 5  
Old 04-26-2013
clue:
Code:
cut -d: -f5 /etc/passwd|more

# 6  
Old 04-26-2013
These are the commands i tried thus far...all i get are a list of all the accounts auch as "apache service user" "sas administrator account" "control-m agent user" "ftp user" "and a whole lot of generic account names
Code:
echo "$(nawk -F: -v user=$(logname) '$1 == user {print $5}' /etc/passwd)"
echo $(grep "$username" /etc/passwd| awk -F: '{print $5}' )
echo $(grep "$username" /etc/passwd| nawk -F: '{print $5}' )

The command you gave returns the same things though in a line to account name. No actual user names are in this list more just account user types
*
Thanks for the assistance though.

Last edited by Franklin52; 04-26-2013 at 09:47 AM.. Reason: Code tags
# 7  
Old 04-26-2013
Seems you are using NIS (+?) or LDAPP then no?
Since you have SAS administrator account you may also be using EG...
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grab shell script error

How do I capture an error for any command I use. For e.g if i try to zip a file and the file is not there. The regualr $? -gt 0 only tells its un-successful but won't tell me that the file is not there when I run through a script. How can I capture this error? for e.g.. zip $x.zip $x... (1 Reply)
Discussion started by: dsravan
1 Replies

2. Shell Programming and Scripting

grab PID of a process and kill it in a script

#!/bin/sh who echo "\r" echo Enter the terminal ID of the user in use: echo "\r" read TERM_ID echo "\r" ps -t $TERM_ID | grep sh echo "\r" echo Enter the process number to end: echo "\r" read PID echo "\r" kill -9 $PID What this code does is ultimately grab the PID of a users sh... (6 Replies)
Discussion started by: psytropic
6 Replies

3. Shell Programming and Scripting

script to grab lines between two values

hi guys say I have a file that contains hello world this is AAAAA message to try BBBBBB and see if anyone AAAAA knows the (3 Replies)
Discussion started by: JamesByars
3 Replies
Login or Register to Ask a Question