| OS X - Operating System General OS operation information and support |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
![]() Member Since: Nov 20, 2007
Posts: 6
![]() |
Hello Mac Experts! I just started drinking the Mac Kool-Aid when I ordered my first Mac - a MBP - last week. I must admit it tastes way better than the Windoze 3 day old cold coffee I'm used to. So far I'm loving it, but I'm running into one issue on my work network.
After trying for 3 hours with our Linux guru we could not get Finder to open a connection to our file/web server which is Debian (Linux) through Samba. I tried everything I could think of and there's not much help on Google. Using the command line mount_smbfs I was finally able to mount the samba share on our Debian to a folder in my home directory. Right now this is fine, for the rest of the day I'll be able to work, but I'm just wondering if there is a way I can create a script that runs when I login that does the following: 1) At login check if my Server is available (192.168.1.216) (this in case I'm using my MBP on the road or from home) 2) Run this command if the server exists: mount_smbfs //myusername:mypassword@192.168.1.216/share /pathto/mountfolder/ondesktop 3) The last part is the key (I guess) - I want this share to show up on my Desktop like when I connect a USB drive or how my Macintosh HD does I'm assuming it's fairlly easy to create a script that runs at login? I've Googled a little with no success but I think the tricky part will making sure the 192.168.1.216 is a valid server -- or maybe there doesn't even need to be a check it just runs the command and if it's not there nothing happens? The other tricky part for me is figuring out where exactly I need to mount the drive to so that it appears on my desktop as a mounted drive instead of in my /Users/username/smbMount folder that I arbitrarily made. The later is what I really need to konw as I'm sure with alot of Googling I can find the best way to create a login script in Leopard, but I have no idea where to mount it to and I'm afraid to just start trying to mount to some device in /dev/ which (I think) could potentially screw things up. I'm looking for a step by step here if someone wouldn't mind helping out this Mac Newb. Thanks in advance!!! |
| QUOTE Thanks | |
![]() Member Since: Nov 20, 2007
Posts: 93
![]() |
There is a write up somewhere (maybe on these forums) about using Automator to do this for you. It can definitely map the "drive" but I'm not sure if it will be able to check to see if the server is available first since I've never used it.
If I find the link, I'll post it here. |
| QUOTE Thanks | |
![]() Member Since: Sep 13, 2006
Location: Deep in the heart of Texas!
Posts: 3,556
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: Mac's
|
|
| QUOTE Thanks | |
![]() Member Since: Nov 20, 2007
Posts: 6
![]() |
The problem is I can't access this share using the finder, for some reason Go > Connect To Server... will not allow me to connect to this Debian server using samba. The only way we've found is to Terminal in mount_smbfs - I'm asking if there is a way to do this during start up - I think I found out how by creating a .command file that runs in startup, but I still don't know how to do (1) check if server exists before creating a folder on my desktop and then mounting the file system to that folder.
Last edited by redbergy; 11-20-2007 at 02:07 PM. Reason: Clarification |
| QUOTE Thanks | |
![]() Member Since: Nov 20, 2007
Posts: 6
![]() |
This is why I am asking about a start up script since it seems the only way I can access this share is by typing in the command line. I have a basic script going below, however I would like it to remove the two directories it creates first at startup, determine whether I can mount the share, then if I can, recreate those folders (that way if I'm not at work, I won't see the empty folders on my desktop)... Below is my script (.command file set to run at login): mkdir /Users/adam/Desktop/blxshare mkdir /Users/adam/Desktop/blxweb mount_smbfs //username:password@192.168.1.216/blxshare /Users/adam/Desktop/blxshare mount_smbfs //username:password@192.168.1.216/blxweb /Users/adam/Desktop/blxweb KillAll Terminal exit So, like I said, first, I need to add a rm /Users/adam/Desktop/blxshare, then I need some way to check and see if 192.168.1.216 exists, if so, recreate the folder and mount the SMB share. |
| QUOTE Thanks | |
![]() Member Since: Nov 20, 2007
Posts: 6
![]() |
Spawn - No problem, I'm not sure of the definition of "successfully". I am able to create a new folder on my desktop and then mount the SMB share to it successfully if that makes sense -- all using the command line.
mkdir /Users/adam/Desktop/blxshare mount_smbfs //username:password@192.168.1.216/blxshare /Users/adam/Desktop/blxshare I cannot get it to "mount" to the desktop using Finder. So to reiterate - the OS doesn't make the share icon on the desktop for me, I have to manually create a new folder on the desktop and use a command to mount to that specific folder. |
| QUOTE Thanks | |
![]() Member Since: Oct 27, 2005
Posts: 4,714
![]() |
This may be a bit left of centre to what you are trying to achieve but if you look at the image below:
![]() When my share is mounted I dragged the icon to the menubar in a Finder window and when the share isn't mounted or if my PC is turned off, the icon reverts to a question mark. When I know my PC is on and I want to mount the share I just click on the question mark and the share is automatically mounted: ![]() I just thought that I should *share* this with you in case it is a workaround. |
| QUOTE Thanks | |
![]() Member Since: Nov 20, 2007
Posts: 6
![]() |
Okay here is my Startup script, currently it supports 2 shares (you can easily edit it to change it to more than 2 or only one) I hope this helps someone else.
Put this into a file with a .command extension and don't forget to hop in the terminal and type chmod +x myfile.command to make sure it has execute permissions. Drag the command file to your login startup applications and you should be good. Code:
#!/bin/sh
# Put Samba Host IP as Host
host="192.168.1.xxx"
# Desktop Path with trailing slash
desktop="/Users/user/Desktop/"
# Share Username
username="yourusername"
# Share Password
password="yourpassword"
# Share 1 Name
shr1="share1"
# Share 2 Name
shr2="share2"
# Ping the host to see if it exists
outp=`ping -c 1 $host | grep "0% packet loss"`
# Based on ping create folders and mount
# or don't mount and delete folders if they exist
if [ "$outp" = "1 packets transmitted, 1 packets received, 0% packet loss" ]; then
echo "Found $host, mounting file systems..."
# Share 1
dir1=${desktop}${shr1}
if [ ! -d "$dir1" ]; then
# Can't Find Directory So Create It
echo "Creating Mount Point: $dir1";
mkdir "$dir1"
else
echo "Found Mount Point: $dir1"
fi
if [ -d "$dir1" ]; then
echo "Mounting..."
mount_smbfs //"$username":"$password"@"$host"/"$dir1" "$desktop""$shr1"
fi
# Share 2
dir2=${desktop}${shr2}
if [ ! -d "$dir2" ]; then
# Can't Find Directory So Create It
echo "Creating Mount Point: $dir2";
mkdir "$dir2"
else
echo "Found Mount Point: $dir2"
fi
if [ -d "$dir1" ]; then
echo "Mounting..."
mount_smbfs //"$username":"$password"@"$host"/"$dir2" "$desktop""$shr2"
fi
else
echo "Could not find $host..."
dir1=${desktop}${shr1}
if [ ! -d "$dir1" ]; then
# Can't Find Directory So Do Nothing
echo "No Unused Mount Point for $dir1"
else
echo "Found Unused Mount Point: $dir1"
echo "Removing..."
rmdir "$dir1"
fi
dir2=${desktop}${shr2}
if [ ! -d "$dir2" ]; then
# Can't Find Directory So Do Nothing
echo "No Unused Mount Point for $dir2"
else
echo "Found Unused Mount Point: $dir2"
echo "Removing..."
rmdir "$dir2"
fi
fi
# NOTE: If you have other Shell Scripts, or the Teriminal.app is running
# enabling the next line will cause the entire Terminal.app to close.
# If you are sure that you can kill the Terminal process feel free to
# uncomment the following line so that the Terminal window the script brings
# up will automatically close when finished
# KillAll Terminal
|
| QUOTE Thanks | |
![]() Member Since: Mar 19, 2007
Location: NY USA
Posts: 1,813
![]() ![]() ![]() ![]() Mac Specs: iMac 5.1 | iMac 7.1 | iPod Touch | iPod Nano
|
Here is my solution, which uses automator:
It's never failed. And you don't have to worry about error checking anything like that. It's an app, so it runs in it's own environment, not dependant on terminal/etc. |
| QUOTE Thanks | |
![]() Member Since: Oct 26, 2008
Posts: 1
![]() |
hello, i was trying to use redbergy's skript, and it writes something like this:
<code> Last login: Sun Oct 26 10:18:48 on ttys000 jarda-vitkus-macbook:~ jardavitku$ /Users/jardavitku/Desktop/mount.command ; exit; Found 192.168.0.148, mounting file systems... Found Mount Point: /Users/jardavitku/Desktop/iTunes Mounting... mount_smbfs: mount error: /Users/jardavitku/Desktop/iTunes: Unknown error: -1 Found Mount Point: /Users/jardavitku/Desktop/Data Mounting... mount_smbfs: mount error: /Users/jardavitku/Desktop/Data: Unknown error: -1 logout [Process completed] <code> creates it two folders with correct names on the desktop, but they are empty. Does anyone now where could be a problem? (finder connection works OK, but startup connection doesn't, it writes that host could not be found) Question number 2): and if it will connect by a this skript, will it be the same asi finder connection? will i be able to eject it in findet? 3): how to asociate to that folder same picture as it is in finder-connected smbs ? thanks for responds.. |
| QUOTE Thanks | |
![]() Member Since: Nov 20, 2007
Posts: 6
![]() |
JaRdaII - Your problem seems to be in the mount_smbfs command:
Quote:
If you don't plan on reusing the script, and don't care that it's modular you can simply change the lines under #Share1 and #Share2 that look like this: Code:
mount_smbfs //"$username":"$password"@"$host"/"$dir1" "$desktop""$shr1" mount_smbfs //"$username":"$password"@"$host"/"$dir2" "$desktop""$shr2" Code:
mount_smbfs //user:password@ip/share /Users/username/Desktop/share We've since added a new file server and the OS now allows us to mount the drives using Finder - so I haven't looked at this script in a while. Edit: After looking over your output again it's possible that you could have your share name wrong (since that isn't ever in the output I'm just guessing) - but make sure that the host computer is configured for windows (samba) file sharing and does in fact have a shared folder with a name that matches your script. Again, this should be pretty easy to test out by opening Terminal and using the mount_smbfs command or checking on the host computer. Hope that helps! Last edited by redbergy; 10-26-2008 at 11:36 AM. Reason: more info |
|
| QUOTE Thanks | ||
![]() Member Since: Jun 30, 2010
Posts: 3
![]() |
Quote:
SHARED > NAS (Windows BSOD icon) > Share (with 3 little people icon) > NormalFolder |
|
| QUOTE Thanks | ||
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| How to: Mount an external usb hard drive? | stamko | OS X - Operating System | 8 | 09-28-2007 07:42 PM |
| Little disk drive looking things on desktop? | brooklyn431 | Switcher Hangout | 9 | 07-05-2007 06:31 AM |
| Creating backups and bootable images... | 2kx2 | Switcher Hangout | 4 | 05-26-2007 08:53 PM |
| Hard Drive Icon On Desktop | KNEE | Apple Notebooks | 13 | 03-08-2007 10:17 AM |
| Upgrading hard drive...Boot IDE or SCSI? | lokerd | Apple Desktops | 5 | 10-19-2003 07:02 PM |
All times are GMT -4. The time now is 02:52 PM.
Powered by vBulletin