osx - mount a drive on Mac OS X with bash script (and NOT use expect) -


i'd mount samba drive in os x using bash. line trick:

mount -t smbfs //$sambauser@$adress/$nameofshare $macosxpath 

only 1 problem. want done without user input - means no password can manually put in. , i'm not going ask users download fink can install expect (as seen here).

i tried applying accepted solution similar stackoverflow problem shown here doing this:

echo "mypassword" | mount -t smbfs //$sambauser@$adress/$nameofshare $macosxpath --stdin 

but no luck - doesn't work , mac os x tells me used mount command improperly:

usage: mount [-dfruvw] [-o options] [-t ufs | external_type] special node    mount [-adfruvw] [-t ufs | external_type]    mount [-dfruvw] special | node 

any suggestions? easy expect script - ruin user experience have prerequisite in mind.

if mount(8) can't call mount syscall on filesystem, looks program it. on freebsd , mac os x, helper programs follow naming convention mount_xxx, xxx -t argument's value.

that means want check mount_smbfs(8) man page, tells -n:

-n    not ask password.  @ run time, mount_smbfs reads ~/library/preferences/nsmb.conf       file additional configuration parameters , password.  if no password found,       mount_smbfs prompts it. 

unfortunately man page trail ends 1 nsmb.conf doesn't mention storing passwords. on freebsd 8.0, @ least, solution to put password key plain text(!) password value under [server:user] heading. type c according linked nsmb.conf man page.

so seems you'll want dump pre-configured nsmb.conf user's ~/library/preferences/ directory , call mount command -n. far know can't provide hashed value, not awesome. i'll try access macbook in few hours test this.

nb: not how gnu toolchain. if you're on linux, you're going using mount.cifs(8). correct solution in that case credentials=filename option (used after -o, of course), filename file of credentials in key=value form, separated newlines. see http://linux.die.net/man/8/mount.cifs


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -