开发者

bat + shell: copy file to remote server?

开发者 https://www.devze.com 2023-02-13 17:18 出处:网络
I\'m trying to create a shell and bat file in which I need to copy some local files to a remote server (I have a Windows and Linux machine).

I'm trying to create a shell and bat file in which I need to copy some local files to a remote server (I have a Windows and Linux machine). However there's no DNS so I have to use the IP.

With a bit of googling I found rcp, but the documentation that I've found so far is a bit fuzzy for windows when using the IP.

So I wa开发者_开发问答s wondering whether anyone had any suggestions as how to do this in a transparant method without having to install additional applications (scp seems to be unknown to Windows XP but RCP is known).


What about ftp? It is usually enabled on Linux and it is available natively in Windows.


Batch script - copy files using from a Windows machine

copy_files.bat

@echo off
set FTPSCRIPT=ftpscript.txt
cd C:\src_dir
echo user_name>>%FTPSCRIPT%
echo pasword>>%FTPSCRIPT%
echo cd /dest_dir>>%FTPSCRIPT%
echo binary>>%FTPSCRIPT%
echo hash>>%FTPSCRIPT%
echo prompt n>>%FTPSCRIPT%
echo mput myfiles*.txt>>%FTPSCRIPT%
echo bye>>%FTPSCRIPT%
ftp -s:%FTPSCRIPT% 1.2.3.4
echo y | del %FTPSCRIPT% > nul

Shell script - copy files using from a Unix machine

copy_files.ksh

cd /src_dir
ftp -i -n -v <<EOF
open 1.2.3.4
user user_name password
cd /dest_dir
binary
hash
mput myfiles*.txt
bye
EOF
0

精彩评论

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