如何在 cygwin bash 脚本中访问共享驱动器?

发布于 2024-11-17 05:48:27 字数 327 浏览 1 评论 0原文

#!/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

书信已泛黄 2024-11-24 05:48:27

我认为 cygwin 中一般不支持 UNC 路径名(即 \\server\share),因此您必须依赖映射到网络驱动器,然后使用 / cygdrive/s。要解决未登录时无法工作的问题,您需要从脚本中调用 Windows NET 程序:

net use s: \\thevault\Shared password /user:myuser 

使用明文密码可能会存在一些安全隐患,因此,另一种可能性是确保脚本是从对此服务器具有读取权限的用户帐户运行的,然后您可以省略密码。

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 Windows NET program from your script:

net use s: \\thevault\Shared password /user:myuser 

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.

花开柳相依 2024-11-24 05:48:27

注销时这似乎工作正常。

#!/bin/bash
lftp ftp://username:[email protected] -e "mirror -R //thevault/Share/folder/folder/folder\ with\ spaces/folder/folder --only-missing -e;exit"

这是我路上的逃生空间。这不起作用的原因是当我重新输入路径时我拼错了共享。 //thevault/shared <~~ 不正确

#!/bin/bash
"mirror -R //thevault/Shared/folder/folder/test --only-missing -e ;exit"

This seems to be working perfectly while logged out.

#!/bin/bash
lftp ftp://username:[email protected] -e "mirror -R //thevault/Share/folder/folder/folder\ with\ spaces/folder/folder --only-missing -e;exit"

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

#!/bin/bash
"mirror -R //thevault/Shared/folder/folder/test --only-missing -e ;exit"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文