Jump to content

Hey guys, I need to mount a network drive without user and password info (connected as a guess is good enough) in Linux via bash script.

 

Background info: The script needs to run and mount the drive every few minutes. It's a medical device that exports a pdf that needs to be imported with another program. The medical device hosts the network drive and is not online all the time. 

 

My plan.
Make a script that mounts the drive as a user (possibly owner of Mount destination) and run the script every few minutes with crontab.

 

Quote

mount -t cifs //*IP*/pdf /opt/*Folder4device*/PDF -o password=

 

Link to comment
https://linustechtips.com/topic/1508963-mount-network-drive-as-user-in-linux/
Share on other sites

Link to post
Share on other sites

2 hours ago, helgehelge123 said:

possibly owner of Mount destination

If you put the mount definition in fstab with `noauto` in the options field, that will allow the mountpoint owner/group to mount and unmount without having to raise permission.

2 hours ago, helgehelge123 said:

The script needs to run and mount the drive every few minutes.

If you end up with stale mount points and file handles this can cause issues, considering

2 hours ago, helgehelge123 said:

a pdf that needs to be imported with another program

the simplest solution would be to wrap the other program with a mount/dismount.

If this program is supposed to be running all the time, then it becomes a little more complicated. The most robust solution would be to watch the ip/port of the device for a the cifs mount to be available, mount it, rsync all the data to a local location, dismount again, then have the "imported with another program" program point to the local location, that way you don't have "users" interacting with a potentially fragile mount point.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×