Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rating: Thread Rating: 31 votes, 5.00 average. Display Modes
Old 03-10-2010, 12:17 PM   #101
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
I edited my previous post and here is a link to the official documentation

http://developer.apple.com/mac/libra...stomLogin.html

It explains the methods
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-10-2010, 12:25 PM   #102
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
thanks for the suggestion but not even loginwindow manager worked. I made sure to set the executable bit on the script by entering the following command

sudo chmod a+x /Library/Scripts/loginscript.sh

I hit the test button in loginwindow manager and the script executes and works great but when I log out and back in nothing happens. Arghh!
lennysweet is offline   Reply With Quote
Old 03-10-2010, 12:27 PM   #103
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
Did you read my link? You need to enable log in hooks in a plist for them to work, or have launchd do it.

Test that out and see what happens, if all else fails maybe after work hours I can get you on chat or something and try to figure it out
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-10-2010, 03:04 PM   #104
Hal Itosis
Hall of Famer
 
Join Date: Apr 2002
Posts: 3,315
Quote:
Originally Posted by lennysweet
this worked great! I used the following

mkdir /Users/$me/Desktop/H_Drive
ln -s /Volumes/ECSERVER/$me /Users/$me/Desktop/H_Drive

and it mapped a folder with an alias inside of it to my network home.

The entire "mkdir" line is not needed, as all it does is add an extra folder into the mix. The original spec (as i recall) was to have an alias on the desktop... not an alias in a folder on the desktop. BTW, "ln -s" was suggested in post #73 back on March 5th (5 days ago).


Quote:
Originally Posted by lennysweet
alias /Volumes/ECSERVER/lenhartj /Users/lenhartj/Desktop/H_Drive

Output:

-bash: alias: /Volumes/ECSERVER/: not found
-bash: alias: /Users/lenhartj/Desktop/H_Drive: not found

FWIW, the "alias" command (shell builtin actually) got errors because -- to bash -- an alias is something totally different: it's a way to rename (or remap) a command (i.e., not an actual physical object in the filesystem which points to another).

E.g., in my ~/.bashrc i have this line:

alias sl='/bin/ln -sv'

IOW, the text sl (SL) has now become a command for creating symbolic links. See 'help alias' for a brief description.

Last edited by Hal Itosis; 03-10-2010 at 03:15 PM.
Hal Itosis is offline   Reply With Quote
Old 03-11-2010, 04:36 AM   #105
kaptagat
Major Leaguer
 
Join Date: Jul 2003
Posts: 329
Hmmm....I have also tried the symbolic link method, here is the script:-
/bin/ln -s /Volumes/Staffh/$1 /Users/$1/Desktop/H_Drive

This works perfectly when run by a user who is already logged on but it also fails when run during the logging on process.

Here is the system log:-

11/03/2010 09:30:33 com.apple.loginwindow[757] 2010-03-11 09:30:33.462 loginwindow[776:203] *** NSTask: Task create for path '/Library/management/link_H_drive' failed: 22, "Invalid argument". Terminating temporary process.
kaptagat is offline   Reply With Quote
Old 03-11-2010, 07:13 AM   #106
kaptagat
Major Leaguer
 
Join Date: Jul 2003
Posts: 329
OK. Got it working as a launch agent.

I also found out that the $1 (currently logged on user) variable does not seem to get passed with launch agents so I went back to the AWK thinghy in the script.

Here is the script (link_H_Drive) that the agent calls, it sits in a folder /Library/management:-

#!/bin/sh
me=$(ls -l /dev/console | awk '{print $3}')
/bin/ln -s /Volumes/St*/$me /Users/$me/Desktop/$me"'s H Drive"

Note the St* is because we have many staff volumes all depending on one's username but they all start with St. Users whose names start with G, would get mounted a volume called Staffg.

Here is the launch agent plist (made with Lingon) which sits in /Library/LaunchAgents :-

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>link H drive</string>
<key>ProgramArguments</key>
<array>
<string>/Library/management/link_H_Drive</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
kaptagat is offline   Reply With Quote
Old 03-11-2010, 11:00 AM   #107
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
hallelujah!!!!

This worked great! Thank you kaptagat. I can now customize this script to work with each building in our school district depending on the server share they are connecting to. I should also be able to easily push out the plist and script file via ARD so deployment should be simple.

I was having trouble but figured out what I was doing wrong. I had the script named loginscript.sh, apparently OSX didn't like the .sh extension, I changed it to .scpt and it worked fine

Thanks again!
lennysweet is offline   Reply With Quote
Old 03-16-2010, 11:11 AM   #108
palan
Prospect
 
Join Date: Feb 2010
Posts: 20
Just to add another complication to this issue.
Using the info in this forum i have managed to redirect the documents folder so it points at the users AD home folder (using a Launchd agent and a script)

Here is a look at our script:

#!/bin/sh
ls -l /dev/console | awk '{print $3}'
TEST=$(ls -l /dev/console | awk '{print $3}')
echo $TEST
sleep 5
if [ -d /Volumes/mactest/$TEST ]; then
mv /Users/$TEST/Documents /Users/$TEST/.Documents.bak
ln -F -s /Volumes/mactest/$TEST /Users/$TEST/Documents
else
STRING1="User has no AD home folder"
echo $STRING1
exit
fi

this script basically checks if the home folder exists, and if it does, renames the documents folder to .documents.bak folder and then creates a symbolic link called Documents which points at the users home folder.

The problem is, that in our Active Directory environment, there could be a number of different locations for students home folders.

example:
home folders could be stored up on \\server1\studenthome\C0000001
(where C0000001 is the users home folder)
In a different faculty it could be \\server2\students\class2010\C0000002

For each area in the college, there maybe between 30 and 50 different server locations that host home folders.

Each Mac (when this is fully tested) will be binded to AD and a Mac server.
on each mac client, the AD plugin is set to "Force local home directory on startup" so the users profile is created locally, but the documents folder is redirected to the users home folder in AD.

So, the question is...Is there a way to get the AD home folder location (either from AD or from the OD server) and store this as a variable on the mac client so we can use it in a script?
palan is offline   Reply With Quote
Old 03-16-2010, 11:39 AM   #109
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
palan

are you using the golden triangle method with OD and AD, or just AD by itself?
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-16-2010, 12:03 PM   #110
palan
Prospect
 
Join Date: Feb 2010
Posts: 20
am using the golden triangle (both AD and OD)
palan is offline   Reply With Quote
Old 03-16-2010, 01:12 PM   #111
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
Quote:
Originally Posted by palan
am using the golden triangle (both AD and OD)

If you look at the key, NFSHomeDirectory in directory services it should display the full path to the user's home. I don't run AD so I can't test this.

example

Code:
dscl . read /Users/tlarkin | grep Home
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-19-2010, 08:19 AM   #112
palan
Prospect
 
Join Date: Feb 2010
Posts: 20
I tried running that command but it just returns
DS error: -14136 (eDSRecordNotFound)

I have looked at the inspector tab within workgroup manager, and for each of our users the variable SMBHome contains the home folder address for each user, so do you know if it is possible to run a command in a script that will output this value?

currently, this value is \\servername\share\classfolder\username, so we would probably need to parse this value so that all we were getting was \share\classfolder\username and we could use ln command to create a symbolic link from the users profile to point at their home folder.

Do you know if its possible to even get this value from the server on the client?
apologies for the never ending questions about this, and thanks for all your help so far
palan is offline   Reply With Quote
Old 03-19-2010, 09:05 AM   #113
palan
Prospect
 
Join Date: Feb 2010
Posts: 20
I posted too soon.
using dscl i have managed to just echo back the SMBHome location of the user that logs in.

my question now is just how to take the info out of the value returned
i.e. its in the form of
\10.0.0.1\homes\classgroup\username

i will need to take the value \homes\classgroup\username
and make it look like
/volumes/homes/classgroup/username

so, basically drop the IP address or server name and change from back slashes to forward slashes.
is this fairly easy to do with a script?
palan is offline   Reply With Quote
Old 03-19-2010, 09:50 AM   #114
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
I was able to pull the exact home folder path for one of my AD users by entering the command

dscl . read /Users/username SMBHome

I would like to use this output in the login script so it creates a symbolic link to the SMBHome path. I tried several things but I keep getting syntax errors. Could anyone shed some light for me?
lennysweet is offline   Reply With Quote
Old 03-19-2010, 10:22 AM   #115
kaptagat
Major Leaguer
 
Join Date: Jul 2003
Posts: 329
You can pipe the output of the dcsl command to a file.
For example :-
dscl . read /Users/abc1 SMBHome > home.txt

The file then contains : SMBHome: \\CRWNSTAH1\Staffh\abc1

I thought about using AWK to extract each pice of data but that won't work because there are not any spaces in the line so no $1, $2, $3 etc.
kaptagat is offline   Reply With Quote
Old 03-19-2010, 10:39 AM   #116
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
is there any way to make the output a variable that can be used to create a symbolic link?

The problem I am having is that the output shows the servername and uses backslashes instead of forward. I need to not only use the output to create a symbolic link but also convert the path into something the mac understands. Here are the steps I'm trying to accomplish, I just can't figure out how to do it via a script with my limited knowledge.

1. grab user's AD home folder path (Done using dscl . read /Users/username SMBHome)
2. take this output and convert it from \\servername\sharename\username to /Volumes/sharename/username
3. create a symbolic link to the home folder to the user's desktop

Right now I am able to do this using the following script...

me=$(ls -l /dev/console | awk '{print $3}')
/bin/ln -s /Volumes/sharename/$me /Users/$me/Desktop/$me" 's Network Drive"

The problem is I have to create a different script every single server we have. If I would be able to grab the user's home folder path using the dscl command it would allow me to create a universal script.
lennysweet is offline   Reply With Quote
Old 03-19-2010, 10:41 AM   #117
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
Can you show me the output of the dscl command with the SMBhome option? I don't have AD at work so I cannot reproduce
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-19-2010, 10:43 AM   #118
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
sure, here is the output of the command dscl . read /Users/balboar SMBHome

SMBHome: \\hs3\classof2011\balboar
lennysweet is offline   Reply With Quote
Old 03-19-2010, 10:51 AM   #119
kaptagat
Major Leaguer
 
Join Date: Jul 2003
Posts: 329
I don't know awk but perhaps the way forward is to pipe the output to a file and use awk's find & replace function to find every \ and replace it with /.

Just a thought.
kaptagat is offline   Reply With Quote
Old 03-19-2010, 10:57 AM   #120
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
Quote:
Originally Posted by lennysweet
sure, here is the output of the command dscl . read /Users/balboar SMBHome

SMBHome: \\hs3\classof2011\balboar

It doesn't mount it anywhere in /Volumes???
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Reply


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

Forum Jump



All times are GMT -5. The time now is 10:17 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.