Ruby读Samba分享
我正在寻找一种从 Samba 共享中读取内容的方法。我想像 Dir
类一样使用它,例如打开和读取目录。这在 Ruby 中可能吗?
I'm looking for a way to read from a samba share. I want to use it like the Dir
class, for example open and read of directories. Is this possible in Ruby?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您的主机操作系统是 Posix(类 UNIX)系统(不确定 Windows...),那么 Sambala gem 应该适合您:
只要您的主机操作系统在 $PATH 中的某处有一个可用的 smbclient 可执行文件,这个 gem 就可以工作。只要您使用 Mac OS X、Linux 或其他一些 UNIX 变体,您就应该能够从终端运行以下命令来查看路径中是否有 smbclient:
如果您没有得到结果,请在 google 上搜索如何获取适用于您当前主机操作系统的 smbclient。如果您使用的是 Mac OS X,则只需安装 MacPorts,然后从终端运行以下命令即可安装 smbclient:
The Sambala gem should work for you if your host OS is a Posix (UNIX-like) system (not sure about Windows...):
This gem will work as long as your host OS has a working smbclient executable somewhere in your $PATH. As long as you're using Mac OS X, Linux, or some other UNIX variant, you should be able to run the following command from the terminal to see if you've got smbclient somewhere in your path:
If you don't get a result, do a google search on how to obtain smbclient for your current host OS. If you're on Mac OS X, you can simply install MacPorts and then run the following command from the terminal to get smbclient installed:
我想你可以尝试检查我的 gem,我已经开始它了,因为我对 sambala 也有同样的问题
https:// github.com/revilo/rsmbclient
I think you could try to check my gem, i've started it cause i've same issues with sambala
https://github.com/reivilo/rsmbclient
Sambala gem 将适用于 Posix(类 UNIX)系统上的 1.8.x Ruby 实现
对于 Posix 上的 1.9.x Ruby,请使用 GLSIGNAL 的 fork。
注意:GLSignal 的 gem 使用丰富的 github 源,该源已修补以在 1.9.x 上运行
正如 lottscarson 所说,只要您的主机操作系统在您的 $PATH 中的某处有一个可用的 smbclient 可执行文件,这些 gem 就可以工作。只要您使用 Mac OS X、Linux 或其他 Posix 变体,您应该能够从终端运行以下命令来查看路径中是否有 smbclient:
如果您没有得到结果,请在 google 上搜索如何获取适用于您当前主机操作系统的 smbclient。 (示例)
作为 smbclient 包装器的替代方案,您可以使用名为“net-smb”的 C 扩展 ruby gem。这需要本机编译,并且不是纯 Ruby 编写的。
这还需要一些东西。
安装示例
The Sambala gem will work for 1.8.x Ruby implementations on a Posix (UNIX-like) system
For 1.9.x Ruby on Posix use GLSIGNAL's fork.
Note: GLSignal's gem uses a github source of abundance that is patched to run on 1.9.x
As stated by lottscarson, these gems will work as long as your host OS has a working smbclient executable somewhere in your $PATH. As long as you're using Mac OS X, Linux, or some other Posix variant, you should be able to run the following command from the terminal to see if you've got smbclient somewhere in your path:
If you don't get a result, do a google search on how to obtain smbclient for your current host OS. (examples)
As an alternative to a wrapper for smbclient you could use a C extension ruby gem called 'net-smb'. This requires native compilation, and is not written pure ruby.
This requires a few things as well.
Installation examples
Ruby_SMB 是 SMB 协议系列的原生 Ruby 实现。
从 自述文件:
Ruby_SMB is a native Ruby implementation of the SMB Protocol Family.
From the README: