Article Title: a complete ftp remote batch shell. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
More than 30 remote hosts in the Organization must upgrade the program from time to time. To facilitate file transfer, sort out the following FTP batch processing programs. The main file is main. THE sh Content format is fixed, and the calling program autopro. sh files can be changed at any time according to the Transfer file and directory
The content of the main. sh file is as follows:
Hostlist = '2017. 1.1.1 198.1.1.2 198.1.1.3 ....................... '# write down the number of Host IP addresses!
Echo
Echo "----- remote FTP batch data transfer ------"
Echo-n "\ n enter the logon username:"; read username
Echo-n "Enter the User Password :"
Stty-echo # Hide the entered password
Read userpwd
Stty echo
Echo "\ n sent to the following HOST: [User name: $ username]"
Echo "$ hostlist"
Echo "\ n start the transfer program, press the Enter key to start .........."
Read goenter
For host in $ hostlist # All host IP loop statements
Do
Echo "sending data to the server $ host .........."
Sh autopro. sh $ host $ username $ userpwd # parameter 1 is the host IP address, parameter 2 is the user name, and parameter 3 is the password
Echo "data transfer is completed on the server $ host !! "
Echo "OK"
Sleep 2
Done
Echo "\ n all data transferred \ n"
The autopro. sh file contains the following content:
Ftp-niv $1 < User $2 $3 # parameters 2 and 3
Bin
Mkdir 20060415 # create a directory on the remote host
Cd 1, 20060415
Mput/20060415/readme.txt # note that the local file storage directory must be the same as the remote host directory
Bye
!