Shell script to mount windows network location in linux machine

可紊 提交于 2019-12-25 16:48:15

问题


I have two questions here. I am able to mount a windows network path in my Ubuntu machine by doing following:

sudo mount -t cifs -o username=user \\\\my_windows\\test /net/loc

All the files and folders present in Windows machine is now available in Ubuntu machine with path '/net/loc'.

Here are my doubts:

  1. I can see all files of windows in linux path. Is it possible to create files/folders in Linux path(the mount path where windows path is mounted) and it will be reflected in Windows machine? I am not able to write in Linux machine where windows network location is mounted. It throws me error "Can't open file for writing".

  2. I am trying to write a shell script (a ksh file) which will mount the windows network path. I wrote the below mount command in my file but this command prompts for password. Is there any way, I can write the command in shell script that it will not ask me for password and I can pass it as either as a parameter or some other mechanism?

    mount -t cifs -o username=user \\my_windows\test /net/loc

Thank you


回答1:


Password can be passed as below

sudo mount -t cifs -o username=${USER},password=${PASSWORD},uid=,gid= //server-address/folder /mount/path/on/ubuntu

And with root access I am able to write in Linux path.

More information is here https://unix.stackexchange.com/questions/68079/mount-cifs-network-drive-write-permissions-and-chown



来源:https://stackoverflow.com/questions/43170818/shell-script-to-mount-windows-network-location-in-linux-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!