FTP folder transmission shell script

Source: Internet
Author: User

######################################## #########################

######################################## #########################

Ftp_download_file ()
{

Echo
Echo begin: Download $1: $2...
Echo

Sleep 0

FTP-I-n <eofdownloadfile
Open $1
User administrator
Bin
Mget $2
Bye
Eofdownloadfile

Echo
Echo end: Download $1: $2...
Echo

Sleep 0

}

Ftp_download_directory ()
{

Echo
Echo begin: Download $1: $2...
Echo

Sleep 0

FTP-I-n <eofdownloaddirectory
Open $1
User administrator
Bin
Mget $2 /*
Bye
Eofdownloaddirectory

Echo
Echo end: Download $1: $2...
Echo

Sleep 0

}

Ftp_upload_file ()
{

Echo
Echo begin: Upload $1: $2...
Echo

Sleep 0

FTP-I-n <eofuploadfile
Open $1
User administrator
Bin
Mput $2
Bye
Eofuploadfile

Echo
Echo end: Upload $1: $2...
Echo

Sleep 0

}

Ftp_upload_directory ()
{

Echo
Echo begin: Upload $1: $2...
Echo

Sleep 0

FTP-I-n <eofuploaddirectory
Open $1
User administrator
Bin
Mput $2 /*
Bye
Eofuploaddirectory

Echo
Echo end: Upload $1: $2...
Echo

Sleep 0

}

Ftp_list_directory ()
{

Echo
Echo begin: list $1: $2...
Echo

Sleep 0

FTP-I-n <eoflistdirectory
Open $1
User administrator
Bin
Ls $2
Bye
Eoflistdirectory

Echo
Echo end: list $1: $2...
Echo

Sleep 0

}

Ls_f_r ()
{

Echo
Echo begin: list $1...
Echo

Sleep 0

Ls-F-r $1

Echo
Echo end: list $1...
Echo

Sleep 0

}

######################################## #########################
#
# Sh: Main
#
# $1:
#
#
######################################## #########################

Echo "****** the name of this program is $0"
Echo "***** the parameters totally passed to this program is $ #"
Echo "****** the parameters are $ *"

Echo
Echo = ***** begin sh...
Echo

Cur_dir = 'pwd'

Remote_ftp_server = "192.168.0.40"

Read-P "Upload (key: U)/download (key: others )? : "Chret
If test u = $ chret
Then

Ls_f_r $ cur_dir

Echo
Echo begin: Upload to remote_pc ========
Echo

Sleep 0

CD $ cur_dir

Ftp_upload_file $ remote_ftp_server $1

Echo
Echo end: Upload to remote_pc ========
Echo

Sleep 0

Ftp_list_directory $ remote_ftp_server/

Else

Ftp_list_directory $ remote_ftp_server/

Echo
Echo begin: Download from remote_pc ========
Echo

Sleep 0

CD $ cur_dir

Ftp_download_file $ remote_ftp_server $1

Echo
Echo end: Download from remote_pc ========
Echo

Sleep 0

Ls_f_r $ cur_dir

Fi

Echo
Echo = ***** end sh...
Echo

Sleep 0

######################################## #########################

######################################## #########################

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.