Shell脚本在Linux机器中挂载Windows网络位置 [英] Shell script to mount windows network location in linux machine

查看:366
本文介绍了Shell脚本在Linux机器中挂载Windows网络位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有两个问题.通过执行以下操作,我可以在Ubuntu计算机中挂载Windows网络路径:

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

Windows机器中存在的所有文件和文件夹现在在Ubuntu机器中都可用,路径为"/net/loc".

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

这是我的疑问:

  1. 我可以在linux路径中看到Windows的所有文件.是否可以在Linux路径(安装Windows路径的安装路径)中创建文件/文件夹,并将其反映在Windows机器中?我无法在装有Windows网络位置的Linux机器上写东西.它引发了错误无法打开文件进行写入".

  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".

我正在尝试编写一个将挂载Windows网络路径的shell脚本(一个ksh文件).我在文件中写入了以下mount命令,但该命令提示输入密码.有什么办法,我可以用shell脚本写命令,它不会询问我密码,我可以将它作为参数或其他机制传递给我吗?

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

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

谢谢

推荐答案

可以按以下方式传递密码

Password can be passed as below

sudo mount -t cifs -o username = $ {USER},password = $ {PASSWORD},uid =,gid =//服务器地址/文件夹/mount/path/on/ubuntu

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

并且具有root访问权限,我能够在Linux路径中编写.

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

更多信息在这里 https://unix.stackexchange .com/questions/68079/mount-cifs-network-drive-write-permissions-chown

这篇关于Shell脚本在Linux机器中挂载Windows网络位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆