如何在 cygwin bash 脚本中访问共享驱动器?
#!/bin/bash
"mirror -R //thevault/Shared/Operations/Marketing/test --only-missing -e ;exit"
我正在使用 lftp 镜像共享驱动器上的文件夹。但它失败并显示“没有这样的文件或目录”,正确的写法是什么?以及如何转义文件名中的空格。我已经尝试了几乎所有的方法。
我也尝试过/cygdrive/s/Operations/Marketing/test
。这在我登录并运行脚本时有效。但是,当任务在我未登录日志文件的情况下运行时,我会得到相同的“没有这样的文件”错误。
#!/bin/bash
"mirror -R //thevault/Shared/Operations/Marketing/test --only-missing -e ;exit"
I'm using lftp to mirror a folder on a share drive. But it fails with "No such file or directory" What's the correct way to write this? and How would I escape a space in the file name. I've tried literally everything.
I've also tried /cygdrive/s/Operations/Marketing/test
. This works while I'm logged in and I run the script. But when the task is run while I'm not logged in the log file I get the same "No such file" Error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为 cygwin 中一般不支持 UNC 路径名(即
\\server\share
),因此您必须依赖映射到网络驱动器,然后使用/ cygdrive/s
。要解决未登录时无法工作的问题,您需要从脚本中调用 WindowsNET
程序:使用明文密码可能会存在一些安全隐患,因此,另一种可能性是确保脚本是从对此服务器具有读取权限的用户帐户运行的,然后您可以省略密码。
I don't think that is support in general in cygwin for UNC pathnames (ie
\\server\share
) so you'll have to rely on mapping to a network drive and then using/cygdrive/s
. To fix the problem with it not working when you aren't logged in, you'll need to call the WindowsNET
program from your script:There may be some security implications to having the password in plaintext, so another possibility is to ensure that the script is running from a user account that has read permission to this server, and then you can omit the password.
注销时这似乎工作正常。
这是我路上的逃生空间。这不起作用的原因是当我重新输入路径时我拼错了共享。 //thevault/shared <~~ 不正确
This seems to be working perfectly while logged out.
It was the escaped spaces in my path. The reason that this didn't work is because when I retyped the path I misspelled share. //thevault/shared <~~ incorrect