当执行 shell 脚本时,将文件从 Windows 复制到 Linux

当执行 shell 脚本时,将文件从 Windows 复制到 Linux

我在 Linux 服务器上有一个程序,它在 Linux 服务器上运行一个 shell 脚本。比如说/tmp/ShellScript.sh

现在我想将位于我的 Windows 计算机位置上的文件复制C:\WindowsFolder\FileToCopy到 Linux 系统目录/tmp,仅当/tmp/ShellScript.sh程序在 Linux 上执行时才执行。

我怎样才能实现这个目标?

我还可以操作脚本/tmp/ShellScript.sh本身并在其中写入逻辑,考虑到它默认是空的。

答案1

首先从 Windows 机器创建共享文件夹 - [c:\windowsfolder]1-

第二步,将 Windows 共享文件夹挂载到你的 Linux 机器上 -

mount -t cifs -o username=<share user>,password=<share password> //WIN_PC_IP/<share name> /mnt/winfolder

运行你的 Linux Shell 脚本,从 /mnt/winfolder(或你想要的其他文件夹)复制到 /tmp

相关内容