简体   繁体   中英

Shell script to mount windows network location in linux machine

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM