开发者

Bat/Shell file copy to Unix/Windows

开发者 https://www.devze.com 2023-02-14 02:38 出处:网络
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.

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

It doesn't matter if I read whether the target machine is Windows/Unix from the command line so an if/else is possible.

But I have no idea on how to start with开发者_高级运维 this without having to modify the rhost file so any input is appreciated.


As long as it as internal network (= security assumptions aside) I would set up a FTP server on the server side and use ncftp on the client side to connect to the server.


Can you use something like scp or sftp (the SSH tools for file transfer)? They are cross-platform, but you will need to set up keys and an SSH server on the destination of the transfer.


From any to any:

  • CIFS, aka Windows File Sharing. Built-in to Windows; requires samba server or smbclient client on Linux. Easy to configure.
  • FTP - Windows comes with a scriptable ftp tool, a similar one exists on Linux. For single-file uploads, however, curl is much easier to use.
  • WebDAV: Can be accessed from Windows in the same way as CIFS shares, and server software exists for both OSes (Apache2 with mod_dav).

From any to Linux:

  • SFTP, which runs over the SSH protocol. The PuTTY SSH client comes with two SFTP clients, psftp and pscp. On Linux, the server (OpenSSH) is usually installed by default.

    (Windows SSH servers exist, but... I don't like them. I don't even know why.)

0

精彩评论

暂无评论...
验证码 换一张
取 消