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-09-2010, 10:41 AM   #81
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
Quote:
Originally Posted by kaptagat
Sorry don't understand. It is a full path. Inside the "share" studhome there are thousands of student folders, one of which is abc1. The studhome volume is automatically mounted on the desktop when AD users logon. Their home folder, quite uselessly (can't "save as" to it), is added to the dock.

Can you post your full script?
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-09-2010, 11:55 AM   #82
kaptagat
Major Leaguer
 
Join Date: Jul 2003
Posts: 329
The script is in post 70. The "real" server share is studenth.
kaptagat is offline   Reply With Quote
Old 03-09-2010, 12:43 PM   #83
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
Quote:
Originally Posted by kaptagat
Thanks Tlarkin but I managed to get it working this way :-

#!/bin/sh

me=$(ls -l /dev/console | awk '{print $3}')
mkalias /volumes/Staffusers/$me /Users/$me/Desktop/H_Drive

--------------------------------

This puts an alias of the user's folder on the desktop.

so taking this info here...let me see if I can shed some light

You have to have this run as a log in hook, by either using launchd to have it run at log in, or modify the loginhook.plist file to tell it to run the script and keep the script on the machines locally.

This is what you did?
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-10-2010, 07:29 AM   #84
kaptagat
Major Leaguer
 
Join Date: Jul 2003
Posts: 329
I am running the script with login window manager which runs all my other scripts perfectly. To test things I changed the script to alias a specific folder of the person logging on, so no $ variables are passed, and it still fails, the system log saying /Volumes/studhomeh/abc1 : no such file or directory.

This also happens when passing the $ variable, it looks for the correct users's folder but can't find it. When run by itself, from the terminal, the script works perfectly, so I think the problem is down to the logging on procedure is so quick that the system doesn't have time to open the mounted volume and scan the 100s of folders for the correct one to alias.
kaptagat is offline   Reply With Quote
Old 03-10-2010, 09:13 AM   #85
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
Quote:
Originally Posted by kaptagat
I am running the script with login window manager which runs all my other scripts perfectly. To test things I changed the script to alias a specific folder of the person logging on, so no $ variables are passed, and it still fails, the system log saying /Volumes/studhomeh/abc1 : no such file or directory.

This also happens when passing the $ variable, it looks for the correct users's folder but can't find it. When run by itself, from the terminal, the script works perfectly, so I think the problem is down to the logging on procedure is so quick that the system doesn't have time to open the mounted volume and scan the 100s of folders for the correct one to alias.

My guess is that the folder is not mounted yet and done so during log in. Try using the sleep command and make your script wait for 60 seconds and see if that makes any difference.
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-10-2010, 09:35 AM   #86
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
I've been playing around with this as well and it's giving me the same result "not found"

I do not think it's a timing issue. If I run the script manually after being logged in a while, it's still saying not found. I also has to change the command from mkalias to alias because the mkalias gave me a "command not found" message

I think we're getting close though, it looks like it might be the format of the path or something simple
lennysweet is offline   Reply With Quote
Old 03-10-2010, 09:39 AM   #87
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
How is the folder being mounted then? If it worked before it was because you had it mounted previously to running the script. You can have it mount the share in the script with the mount command, but if you did not do that before how was it being mounted?
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-10-2010, 09:47 AM   #88
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
The volume is being mounted at login and is called ECSERVER, here is the command I'm trying to run manually and in the script. ECSERVER is mounted on the destkop as I run the command.

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

If I run the command with mkalias the output reads "mkalias: Command not found"

is my syntax incorrect?
lennysweet is offline   Reply With Quote
Old 03-10-2010, 09:51 AM   #89
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
just a follow up, if I run the command ls /Volumes/ECSERVER/lenhartj it works fine and lists the contents of my folder
lennysweet is offline   Reply With Quote
Old 03-10-2010, 09:58 AM   #90
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
can you run this command and post the output?

ls -al /Volumes

Do it though after the share is mounted so we can see the mount point.
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-10-2010, 10:05 AM   #91
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
Sure thing, here is the output, looks like ECSERVER is in the list

TECH-IMAC:~ admin$ ls -al /Volumes
total 8
drwxrwxrwt@ 4 root admin 136 Mar 10 09:49 .
drwxrwxr-t 36 root admin 1292 Jan 14 12:35 ..
drwx------@ 112 admin staff 3764 Mar 8 08:01 ECSERVER
lrwxr-xr-x 1 root admin 1 Mar 8 15:08 TECH-IMAC -> /
TECH-IMAC:~ admin$
lennysweet is offline   Reply With Quote
Old 03-10-2010, 10:24 AM   #92
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
Try using the mkdir command to make the directory first for h_drive, then either alias it or use a symbolic link (ln -s). I mean we need to do it step by step to find out the missing step or location of failure, that way we can script it. You said it worked once, but nothing has changed and now it doesn't?
__________________
sudo make me a sammich

Last edited by tlarkin; 03-10-2010 at 10:30 AM.
tlarkin is offline   Reply With Quote
Old 03-10-2010, 10:34 AM   #93
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
this worked great! I used the following and it mapped a folder with an alias inside of it to my network home.

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

The only problem is I can't get the script to run using WGM. I added my imac in a test user group, then added this as a login script in Preferences>Login>Scripts

I logged in as me and nothing happened, is there some MCX refresh I need to perform?
lennysweet is offline   Reply With Quote
Old 03-10-2010, 10:44 AM   #94
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
In WGM, only computer groups can run log in hooks, not user groups. So you would have to create computer groups to do so.

Another way is to modify the loginhook.plist file and have it run the script, another way would be to have launchd run it from /Library/LaunchAgents, which will run anytime any user logs in.
__________________
sudo make me a sammich
tlarkin is offline   Reply With Quote
Old 03-10-2010, 11:15 AM   #95
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
how can I run it from /Library/LaunchAgents

I dropped the script in that folder but nothing happens, could you tell me what I'll need to do to get launchd to run it at login?
lennysweet is offline   Reply With Quote
Old 03-10-2010, 11:20 AM   #96
kaptagat
Major Leaguer
 
Join Date: Jul 2003
Posts: 329
Lennysweet:

Your mkalias command not found is caused because the path to the command is missing. I had to put the full path as below when running the command from a script:-

/usr/local/bin/mkalias /volumes.....

I use Mike Bombich's LoginWindow Manager to launch scripts at login and logout. It is quite old now and complains about fonts when you start it up but it still works right up to 10.6.

tlarkin :

Adding a sleep period didn't make any difference.

Last edited by kaptagat; 03-10-2010 at 11:24 AM.
kaptagat is offline   Reply With Quote
Old 03-10-2010, 11:22 AM   #97
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
the ln -s is working fine, my problem now is I can't seem to get it to run at login. Could you give me details instructions for getting this script to run for any user who logs in?
lennysweet is offline   Reply With Quote
Old 03-10-2010, 11:37 AM   #98
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
create a luanchd agent like so:

Code:
<?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>com.mycompany.loginhook</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Library/Scripts/myloginscript.sh</string>
	</array>
</dict>
</plist>
Then place this agent in /Library/LaunchAgents and make sure to give it the plist extension. Then place your log in script in /Library/Scripts, or where ever you want adjusting the path.

Then use launchctl to load your launchd item permanently.

(run as root)
Code:
sudo launchctl -w load /Library/LaunchAgents/com.mycompany.loginhook.plist


Now anytime, any user logs in, it will run. You can also modify the local file /Library/Preferences/com.apple.loginwindow.plist to have it run the script as well.

If you import computer names into WGM you can manage it by computer groups, or create a guest computer and assign it that way. However, a guest computer will get assigned to all macs in your deployment, as it is the default computer for all computer groups.

---EDIT----

I went back and outlined what you would have to fill in for your settings. After it is loaded you may have to reboot to get the agent to run. To ensure it is running you can use launchctl list command to see if your agent is listed.

I have used this method in the past at my work and it has worked for me for automating scripts.
__________________
sudo make me a sammich

Last edited by tlarkin; 03-10-2010 at 12:15 PM.
tlarkin is offline   Reply With Quote
Old 03-10-2010, 11:58 AM   #99
lennysweet
Triple-A Player
 
Join Date: Jun 2008
Posts: 92
Wow, that's quite a process. I tried it and of course, it didn't work for me. When I ran the launchctl command with -w argument it said it could not be found. I removed it and got a "dubious ownership" error.

At this point I pasted the text into a file and named it com.rlasd.loginhook.plist and saved it into the Launchagents folder. I then save the the script named loginscript.sh into the scripts folder. I made sure all of the paths were correct so I'm not sure what I'm doing wrong.

Why does something as simple as a login script take so much command line knowhow geez!
lennysweet is offline   Reply With Quote
Old 03-10-2010, 12:04 PM   #100
kaptagat
Major Leaguer
 
Join Date: Jul 2003
Posts: 329
Lennysweet:

Use loginwindow manager. It is very simple, you just drag your script into a run shell script at login box, tick the box and tick apply. Nothing could be simpler. It is also free.
kaptagat 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.