简体   繁体   English

使用批处理文件或 shell 脚本传输文件

[英]file transfer using batch file or shell script

I want to transfer .txt file from window system to linux server using wan ip (using root name and password) using batch file is that any options.我想使用 wan ip(使用 root 名称和密码)使用批处理文件将 .txt 文件从窗口系统传输到 linux 服务器是任何选项。

either any option from linux to window file access using shell script please reply me.无论是从 linux 到使用 shell 脚本访问窗口文件的任何选项,请回复我。

Thanks HM Suthar谢谢 HM Suthar

You can usepscp for this.您可以为此使用pscp Download it, then create a .bat file with this in:下载它,然后在以下位置创建一个 .bat 文件:

@echo off
start """ "C:\Location\To\pscp" -r -pw PASSWORD C:\File\To\Upload.txt root@IP.AD.DR.ESS:/path/to/upload/to

I usually deal with it from the source server rather than the receiving server but it doesnt matter.我通常从源服务器而不是接收服务器处理它,但这并不重要。 The following is a very basic linux shell script for FTP'ing以下是一个非常基本的用于 FTP 的 linux shell 脚本

#/usr/bin/ksh

FTPFILE=ftpfile.txt
FTPDIR=directorytomoveto

ftp -nv <<EOF 
open ip_address_goes_here
user username password
prompt
binary
lcd $FTPDIR
get $FTPFILE
bye
EOF

exit 0

Bare in mind this is incredibly basic and involves hardcoding the username/password into the file.请记住,这是非常基本的,涉及将用户名/密码硬编码到文件中。

As it is a WAN do you really want to use FTP.因为它是一个广域网,你真的想使用 FTP 吗?

Here are a few useful links which contain much much more information:以下是一些有用的链接,其中包含更多信息:

http://www.stratigery.com/scripting.ftp.html http://www.computerhope.com/unix/ftp.htm http://www.stratigery.com/scripting.ftp.html http://www.computerhope.com/unix/ftp.htm

take a look at the man page for ftp on linux查看 linux 上 ftp 的手册页

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

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