1. 概述
Linux强大的命令行,能够完成各种不同的功能。然而,如果只是无休止的输入命令来完成功能,那么就太有点费事了。那么怎么能够解决这个问题了? Linux shell脚本给我们提供了答案。通过shell编程可以把命令进行组合,去自动的完成管理与执行任务。而不需要一次又一次的输入命令。这篇文章中,主要介绍一下,怎么利用shell脚本去完成自动下载文件的功能。
2. 基本知识
(1) Linux shell编程基础-包括awk,sed,正则表达式,在前面已经介绍过了。
(2)ftp,lftp
FTP是一个文件传输协议,分为主动传输与被动传输,而传送的方式有binary和acsii两种,get用于下载文件,put用于上传文件。
FTP is the user interface to the ARPANET standard File Transfer Proto-
col. The program allows a user to transfer files to and from a remote
network site
-n 禁止自动登录
-i 关闭交互式ftp,默认情况下ftp是一种交互式操作
-n Restrains ftp from attempting ‘‘auto-login’’
-i Turns off interactive prompting during multiple file transfers.
! [command] [args]]
Invoke an interactive shell on the local machine. If there are
arguments, the first is taken to be a command to execute
directly, with the rest of the arguments as its arguments.
! -代表回到shell脚本
get remote-file [local-file]
Retrieve the file remote-file and store it on the local machine.
If the local fi