windows 自动从Unix服务器下载日志文件到Windows机器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2139359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:49:21  来源:igfitidea点击:

Automatically download log file from Unix server to Windows machine

windowsunixlogfiles

提问by Alex

I have a Unix server on which a continuously running application generates a large text log. (aprox. 100megs an hour).

我有一台 Unix 服务器,在该服务器上连续运行的应用程序会生成一个大文本日志。(大约 100megs 每小时)。

My main development machine is a Windows computer and to see what's going on with the application I use Filezilla to download the log file to the PC where I use notepad++ to go thru log entries.

我的主要开发机器是一台 Windows 计算机,为了查看应用程序的运行情况,我使用 Filezilla 将日志文件下载到我使用 notepad++ 浏览日志条目的 PC。

The whole process seems a bit convoluted to me - so could you recommend a tool that I could run on my PC to connect to the Unix box and automatically download the log file - so I could dissect it on my Windows machine where I have all the required tools (my Unix access is very restricted - so viewing a log file on the Unix box is not really an option).

整个过程对我来说似乎有点复杂 - 所以你能推荐一个我可以在我的 PC 上运行的工具来连接到 Unix 机器并自动下载日志文件 - 所以我可以在我的 Windows 机器上剖析它,我拥有所有所需的工具(我的 Unix 访问非常受限 - 所以在 Unix 机器上查看日志文件并不是一个真正的选择)。

Thank you.

谢谢你。

回答by paxdiablo

Windows itself has these tools. Use ftp to get the file. You can set up a file called snatch.ftp:

Windows 本身就有这些工具。使用 ftp 获取文件。您可以设置一个名为 snatch.ftp 的文件:

user
USERNAME
PASSWORD
get /location/of/logfile.txt logfile.txt
bye

(with suitable values of USER and PASSWORD) then have a command file (snatch.cmd) run by scheduled tasks on whatever schedule you desire:

(具有适当的 USER 和 PASSWORD 值)然后让snatch.cmd计划任务按您想要的任何计划运行命令文件 ( ):

ftp -n -s:snatch.ftp

I have to say though that generating 100M an hour is not a very good idea for any log file. It may be that this is necessary but you should examine whyso much data is being generated and whether it is really necessary.

我不得不说,虽然每小时生成 100M 对于任何日志文件来说都不是一个好主意。这可能是必要的,但您应该检查为什么生成如此多的数据以及它是否真的有必要。

Shifting 100M an hour across the network is also something I'd be circumspect of as well. I know you stated that you don't have a lot of access to the UNIX side but I'd still be looking at that as the first choice, especially since the text processing tools under UNIX are more than up to the task.

在网络上每小时移动 100M 也是我会谨慎的事情。我知道您说过您对 UNIX 方面没有太多访问权限,但我仍然将其视为首选,尤其是因为 UNIX 下的文本处理工具能够胜任这项任务。

At a bare minimum, think about filtering the log file a little on the UNIX side before copying it to your own box. Your network administrators will be eternally grateful :-)

在将日志文件复制到您自己的机器之前,至少要考虑在 UNIX 端稍微过滤日志文件。您的网络管理员将永远感激:-)

回答by SF.

it looks like the easiest and most fault-proof way would be to get WGet for Windows and call it with the syntax of wget ftp://login:password@host/path/filefrom a batch file.

看起来最简单和最防故障的方法是获取 WGet for Windows 并 使用批处理文件中的 wget ftp://login:password@host/path/file语法调用它。

回答by Adam Liss

Can you use the Windows "scheduled jobs" feature to invoke your ftp client periodically?

您可以使用 Windows 的“计划作业”功能定期调用您的 ftp 客户端吗?

Or, going the other way, can your Unix box push the file to a place that's easier for you to access, such as a shared drive?

或者,反过来说,您的 Unix 机器能否将文件推送到您更容易访问的地方,例如共享驱动器?

回答by ghostdog74

you can create a batch file to ftp(file transfer) your log file to your PC. An example, imagine your unix server is 10.10.10.10, so you create a file called ftp.txt,

您可以创建一个批处理文件来 ftp(文件传输)您的日志文件到您的 PC。例如,假设您的 unix 服务器是 10.10.10.10,因此您创建了一个名为 ftp.txt 的文件,

open 10.10.10.10
anonymous
[email protected]
cd path
get file.log
quit 

then on the command line

然后在命令行

c:\test> ftp -s:file.txt 
c:\test> notepad file.log

Alternative, since you have FileZilla, you may look at the documentation to see if there are any command line you can use instead of the windows ftp client.

或者,由于您有 FileZilla,您可以查看文档以查看是否有任何命令行可以代替 windows ftp 客户端使用。

回答by Yada

Automate downloading the log file from UNIX system using ftp batch command.

使用 ftp 批处理命令从 UNIX 系统自动下载日志文件。

FTP (file transfer protocol) is a file transfer utility commonly used with UNIX systems.

FTP(文件传输协议)是 UNIX 系统常用的文件传输实用程序。

FTP is capable of using scripts (lists of commands from external files). The following example demonstrates a script that opens a connection to IP address 11.11.11.11, logs on to the host as a guest with the password "guest," uploads the File1 file, and then quits:

FTP 能够使用脚本(来自外部文件的命令列表)。以下示例演示了一个脚本,该脚本打开与 IP 地址 11.11.11.11 的连接,以访客身份使用密码“guest”登录主机,上传 File1 文件,然后退出:

open 11.11.11.11
user
guest
guest
put file1
quit

http://support.microsoft.com/kb/96269

http://support.microsoft.com/kb/96269