Use here documentation
Copy Code code as follows:
#!/bin/sh
FTP-IVN 210.29.28.124 <<eof
User Yun yun2011
Lcd/home/veyun
Cd/home/veyun/yhb
Get V
Bye
Eof
Explain:
-I: Turns off interactive prompts during multiple file transfers, so there's no hint that users can enter user names and passwords
-N: Automatic logon When initial connection is blocked
-V: Set the FTP command to verbose mode so that you can see the commands in the session
In this example, log in using the username Yun and password yun2011.
Here's a simple shell script that you wrote yourself.
Implementation objective: Download the file from Remotedir to the Localdir directory and list all Remotedir file names into Dirlist file.
Finally, the downloaded file is packaged, and the file that you just downloaded (according to the filename in dirlist) is deleted.
Script Explanation:
2-8: Defining variables
9-16:ftp Download
18-20: Packing
22: Get the filename in the Dirlist file
23-26: Get the file name, and delete the corresponding file.