Is there anyway to specify / pass a username password to gvfs-mount so that I can run it from a script without it waiting for the user to specify input?
How about using a simple expect script? Something like this...you will need to change...just an outline
#!/usr/local/bin/expect -- set timeout -1 spawn gvfs-mount {args} expect "User" send "joe\n" expect "Password:" send "xxxxx\n"
smb urls generally work along these lines:
smb://[[domain;]username[:password]@]server[/share[/path]]
I haven't tested gvfs-mount will accept the password like this but certainly it works for username and domain. gvfs-mount can just uses a stored password, if the user has stored one.
This may be an older post but I didn't get it to work when I needed it recently. Now I have found a solution on the german Ubuntu Wiki. It works like a charm now.
Have a file with your login data, leave a blank line if you don't need e.g. the Domain (order as gvfs-mount asks for it):
username
domain
password
Then, in your script, simply call gvfs-mount smb://server/path < path/to/login/data
, and here you go! I think you could also do it without a file, passing a string like that: echo 'username\ndomain\npassword' | gvfs-mount smb://server/path
, but it didn't work when I tried. I don't know why, it suddenly didn't ask for a password or something...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With