php - 如何使用 php 从 Ubuntu 访问 Windows 驱动器中的远程文件

标签 php windows linux exec network-drive

我在 Windows 中有这个命令:

exec('copy /V "'.$file.'" "'.$dest.'"');

其中 $file 是 Windows 驱动器中的 REMOTE 文件,其形式为:

\\server\dr1$\folder\file
\\server\dr2$\folder\file
\\server\dr0$\folder\file
\\server\dr1$\folder\file2
\\server\dr1$\folder\file1

等等。目标是服务器中的本地文件。请注意,驱动器一直在变化,并且事先并不知道(它们来自数据库结果)。在Windows中一切都很好,执行的命令将是这样的(/V是验证文件是否正确复制):

copy /V \\server\dr1$\folder\file c:\users\test\file

但是,当我尝试时,我不知道如何在 Linux 中运行它

cp \\server\dr1$\folder\file /home/test/file

我得到:

cp: cannot stat '\\server\dr1$\folder\file': No such file or directory.

谢谢

纳米。

最佳答案

您需要使用 Samba/CIFS 来装载驱动器,然后再向驱动器复制或从驱动器复制。

这看起来像:

mount -t cifs //servername/sharename ./mountpoint/
cp ./mntpoint/folder/file /home/test/file

有很多关于这方面的文档。尝试谷歌搜索 smbclient 或 cifs。

关于php - 如何使用 php 从 Ubuntu 访问 Windows 驱动器中的远程文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5384290/

相关文章:

php - 变量前的&符号是什么意思?

javascript - 在 php 函数内部时,Sql 查询不起作用

windows - 运行给定目录中的所有批处理文件

php - Codeigniter Pagination 类限制

php while循环/foreach插入sql问题

Java 程序无法在 Vista 32 位上运行

python - Windows WSL 的 Poetry 安装不起作用,忽略 $HOME

c - Malloc 内存问题

java - 运行 jar 时出现 ClassNotFoundException

php - 查找字符串超过 50 个字符的 php 文件