Utilize shell scripts,linux commands, open source tools,java, to Maximize the Power of Linux.
Focused on working with linux and shell, search engine technology including Chinese segmenter
Any questions please contact me at gmail: david.ullua

1/25/2007

利用~/.netrc文件自动ftp下载文件 (当天或昨天的tomcat日志)

home目录中添加文件.netrc,内容如下:

#download files begin with test under user david's home

machine 172.16.100.30 login david password 3287

macdef init

binary

prompt

!clear

mget test*

!clear

bye


#get the log of yesterday:

#echo "catalina.`date --date='1 days ago' +%Y-%m-%d `.log" | ftp www.kseeker.com

#download file specified by the second arg (the log filename)

machine www.kseeker.com login david password pass92342@#$@**(89

macdef init

binary

prompt

cd /home/tomcat/logs

mget $2

bye


注意:bye后要有一空行,.netrc文件的属性须是600,

可以使用这个命令下载172.16.100.30上面/home/david/目录test开头的文件:%ftp 172.16.100.30


可以使用这个命令来下载服务器上昨天的tomcat日志(文件名如: catalina.2007-01-24.log):

%echo "catalina.`date --date='1 days ago' +%Y-%m-%d `.log" | ftp www.kseeker.com

man netrc, 可以看到更多信息:

NETRC(5) BSD File Formats Manual NETRC(5)

NAME

netrc, .netrc -- user configuration for ftp

DESCRIPTION

This file contains configuration and autologin information for the File Transfer Protocol client ftp(1).

The .netrc file contains login and initialization information used by the auto-login process. It resides in the user's

home directory. The following tokens are recognized; they may be separated by spaces, tabs, or new-lines:

......

1 comment:

Anonymous said...

It is not my first time to pay a visit this web page, i am visiting this site dailly
and obtain pleasant facts from here all the time.


Take a look at my web-site - spinrewriter5review.com

About Me

I am a senior developer and a team leader with 3 years development experience in Suzhou, China, focus on mobile web search, linux, Java and machine learning in NLP (natural language processing). My goal is to improve people's life with computer technology.