简体   繁体   English

Bat / Shell文件复制到Unix / Windows

[英]Bat/Shell file copy to Unix/Windows

I got the task to write a script to do some tasks, one of those is to copy some files from the local machine to a server directory. 我得到了编写脚本来执行某些任务的任务,其中之一是将某些文件从本地计算机复制到服务器目录。 Now this isn't exactly my area of expertise, so I was wondering if anyone could give me some advice/pointers. 现在这不是我的专业领域,所以我想知道是否有人可以给我一些建议/指标。

They gave me the following requirements: 1) same script needs to be capable of copying to a Windows AND Unix machine 2) no files should be modified (such as .rhost) 3) Bat file for the Windows machines, Shell script for the Unix machines 他们给了我以下要求:1)相同的脚本需要能够复制到Windows和Unix计算机上2)无需修改任何文件(例如.rhost)3)Windows计算机的Bat文件,Unix的Shell脚本机器

It doesn't matter if I read whether the target machine is Windows/Unix from the command line so an if/else is possible. 是否从命令行读取目标计算机是否为Windows / Unix无关紧要,因此可以使用if / else。

But I have no idea on how to start with this without having to modify the rhost file so any input is appreciated. 但是我不知道如何从此开始而不需要修改rhost文件,因此不胜感激任何输入。

只要是内部网络(不考虑安全性假设),我都将在服务器端设置一个FTP服务器,并在客户端使用ncftp连接到服务器。

Can you use something like scp or sftp (the SSH tools for file transfer)? 可以使用诸如scpsftp (用于文件传输的SSH工具)之类的东西吗? They are cross-platform, but you will need to set up keys and an SSH server on the destination of the transfer. 它们是跨平台的,但是您将需要在传输目的地上设置密钥和SSH服务器。

From any to any: 从任何到任何:

  • CIFS, aka Windows File Sharing. CIFS,又名Windows文件共享。 Built-in to Windows; 内置于Windows; requires samba server or smbclient client on Linux. 在Linux上需要samba服务器或smbclient客户端。 Easy to configure. 易于配置。
  • FTP - Windows comes with a scriptable ftp tool, a similar one exists on Linux. FTP-Windows附带可编写脚本的ftp工具,Linux上也存在类似的工具。 For single-file uploads, however, curl is much easier to use. 但是,对于单文件上传, curl更加易于使用。
  • WebDAV: Can be accessed from Windows in the same way as CIFS shares, and server software exists for both OSes (Apache2 with mod_dav). WebDAV:可以通过Windows以与CIFS共享相同的方式进行访问,并且两个操作系统都具有服务器软件(带有mod_dav的Apache2)。

From any to Linux: 从任何版本到Linux:

  • SFTP, which runs over the SSH protocol. SFTP,它通过SSH协议运行。 The PuTTY SSH client comes with two SFTP clients, psftp and pscp . PuTTY SSH客户端带有两个SFTP客户端, psftppscp On Linux, the server (OpenSSH) is usually installed by default. 在Linux上,通常默认情况下安装服务器(OpenSSH)。

    (Windows SSH servers exist, but... I don't like them. I don't even know why.) (存在Windows SSH服务器,但是...我不喜欢它们。我什至不知道为什么。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM