Use the here document
Copy codeThe Code is 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
Explanation:
-I: Disable interaction prompts during multi-file transmission, so there will be no prompts for users to enter their usernames and passwords.
-N: Automatic Logon during initial connection is blocked.
-V: Set the ftp command to verbose mode, so that you can see the command in the session
In this example, log on with the username yun and password yun2011.
The following is a simple shell script written by myself.
Purpose: download the file from remotedir to the localdir directory, and list all the remotedir file names to the dirlist file,
Finally, package the downloaded file and delete the downloaded file (based on the file name in dirlist ).
Script explanation:
2-8: define variables
9-16: ftp download
18-20: Packaging
22: get the file name in the dirlist File
23-26: get the file names one by one and delete the corresponding files.