Last active
August 29, 2015 14:16
-
-
Save BaconSoap/f3f568aa04f4fd7c230f to your computer and use it in GitHub Desktop.
Script to connect to Windows via command line on an OS X machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
WINDOWSHOST = "//user@guest-hostname" | |
SHAREDIR = "~/smb" | |
# make sure the mount dir on host exists | |
if [ ! -d "$SHAREDIR/$1" ]; then | |
mkdir "$SHAREDIR/$1" | |
fi | |
# if there's something in the mount, because either share is active or files | |
# are hanging around, cancel the mount process | |
if find "$SHAREDIR/$1" -maxdepth 0 -empty | read v; then | |
rm -rf "$SHAREDIR/$1" | |
mkdir "$SHAREDIR/$1" | |
mount -t smbfs "$WINDOWSHOST/$1" "$SHAREDIR/$1" | |
fi | |
# move into the mount and enumerate all files to fill the cache | |
cd "$SHAREDIR/$1" | |
ls -laR > /dev/null | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment