Get username in script | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Get username in script

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-12-2007
willc0de4food willc0de4food is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 12 February 2007, 5:52 PM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Get username in script

how would i go about getting the username of the person currently logged in, and then using the username in a shell script? i've tried variations of
user=whoami , 'whoami' , $whoami , and none of the above work lol
I'd like to get the username to then mount a network share such that the command would be,
mount_afp afp://username@dc.fqdns.edu/username /Users/username/Desktop/Home

any help on how to accomplish this would be IMMENSELY appreciated :] thanks
Sponsored Links
    #2  
Old 02-12-2007
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 18 December 2014, 9:48 PM EST
Location: Bangalore
Posts: 296
Thanks: 8
Thanked 1 Time in 1 Post
try this

export user=`eval whoami`
or export user=$(whoami)
echo $user
The Following User Says Thank You to ahmedwaseem2000 For This Useful Post:
Bill L. (07-21-2010)
Sponsored Links
    #3  
Old 02-12-2007
willc0de4food willc0de4food is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 12 February 2007, 5:52 PM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by ahmedwaseem2000
try this

export user=`eval whoami`
or export user=$(whoami)
echo $user
assuming one of these methods works, would that then allow me to execute a command such as..
mount_afp afp://$user@dc.fqdns.edu/$user /Users/$user/Desktop/Home
?

thanks :]



/* edit */ the second method worked, export user=$(whoami)
when i try: mount_afp afp://$user@dc.fqdns.edu/$user /Users/$user/Desktop/Home
i get this error:
Quote:
mount_afp: AFPMountURL returned error -50, errno is -50
=\ google doesn't help much.

Last edited by willc0de4food; 02-12-2007 at 04:40 PM..
    #4  
Old 02-12-2007
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 18 December 2014, 9:48 PM EST
Location: Bangalore
Posts: 296
Thanks: 8
Thanked 1 Time in 1 Post
I am not sure of mounting devices, but following the unix syntax you could try

mount_afp afp://${user}@dc.fqdns.edu/${user} /Users/${user}/Desktop/Home

do let me know if it works?
Sponsored Links
    #5  
Old 02-12-2007
willc0de4food willc0de4food is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 12 February 2007, 5:52 PM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
mm..i believe the problem is it wants the password? the command is supposed to be setup as afp://username:password@dc.fqdn.edu/.... but if the computers already logged in to active directory, itd be nice if the password wasn't required. otherwise there would have to be some form of input (i'm guessing) to get the password?
=\

Last edited by reborg; 02-12-2007 at 07:19 PM..
Sponsored Links
    #6  
Old 02-12-2007
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 18 December 2014, 9:48 PM EST
Location: Bangalore
Posts: 296
Thanks: 8
Thanked 1 Time in 1 Post
If you are talking about retreiving the passwords from unix box then forget it because in unix the passwords are stored in the encrypted format which even the administrators cant retreived.

for further reference you could try this link.

http://www.hmug.org/man/8/mount_afp.php
Sponsored Links
    #7  
Old 02-12-2007
willc0de4food willc0de4food is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 12 February 2007, 5:52 PM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
no, i dont mean retrieving passwords.. i mean prompting the user to enter their password and using that in the shell script. except i'm unsure how i'd like to go about this or if i should just try some crazy concotion of applescript/shell script..maybe use a shell script to execute an applescript. lol thanks for your help though :]
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to see if a username is valid. TheRealNapsta UNIX for Dummies Questions & Answers 1 11-08-2011 11:28 AM
Using a script to check the login and username (html) hakermania Programming 4 03-21-2010 05:08 PM
Need to modify a file of different username through script. dashok.83 Shell Programming and Scripting 2 11-27-2008 12:17 AM
Find username of user running the script garric Shell Programming and Scripting 1 06-10-2008 04:44 AM
username password in script roshanjain2 Shell Programming and Scripting 5 02-13-2007 05:47 AM



All times are GMT -4. The time now is 06:45 AM.