ftp上傳下載記錄

來源:互聯網
上載者:User

標籤:安裝包   target   script   --   attr   comment   x86   tab   ice   

1,準備ftp環境
下載最新的ftp用戶端:https://filezilla-project.org/ftp/001.png,選擇linux下面的版本,如002.png所示:在window10下面下載,使用wget http://sourceforge.net/projects/filezilla/files/FileZilla_Client/3.26.1/FileZilla_3.26.1_i586-linux-gnu.tar.bz2在linux命令列裡面下載。解壓縮,tar -xvf FileZilla_3.26.1_i586-linux-gnu.tar.bz2安裝ftp: yum install vsftpd -y啟動:service vsftpd start嘗試ftp命令,報錯[root@hch_test_dbm1_121_62 bin]# ftp-bash: ftp: command not found[root@hch_test_dbm1_121_62 bin]#直接下載ftp安裝包 wget http://mirror.centos.org/centos/6/os/x86_64/Packages/ftp-0.17-54.el6.x86_64.rpm然後安裝[root@hch_test_dbm1_121_62 soft]# rpm -ivh ftp-0.17-54.el6.x86_64.rpm Preparing...                ########################################### [100%]   1:ftp                    ########################################### [100%][root@hch_test_dbm1_121_62 soft]# 安裝報錯libc.so.6 is needed by ftp-0.17-35.el5.i386去安裝rpm –Uvh http://mirror.centos.org/centos/6/os/x86_64/Packages/glibc-2.12-1.132.el6.x86_64.rpm嘗試ftp操作[root@hch_test_dbm1_121_62 soft]# ftpftp> 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27



2,自動登入下載
#!/bin/bashftp -n<<!open 120.132.27.91 10000user downdata RakudespuH3bAk+ruybinarycd uplcd /home/mysql/binlogspromptmget mysql-bin*closebye!
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12



3,自動登入上傳
#本地的/home/databackup to ftp伺服器上的/home/data#####!/bin/bashftp -n<<!open 192.168.1.171user guest 123456binaryhashcd /home/datalcd /home/databackuppromptmput *closebye!
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14



4,涉及的技巧
#!/bin/bash#提取檔案名稱,刪除尾碼。file_name="text.gif"name=${file_name%.*}echo file name is: $name輸出結果:file name is: test從右邊到左邊的匹配操作 :% 和 %% 操作符的樣本[[email protected]_test_dbm1_121_62 load_binlog]# filename=mysql-bin.000110.zip[[email protected]_test_dbm1_121_62 load_binlog]# name=${filename%.*}[[email protected]_test_dbm1_121_62 load_binlog]# echo $namemysql-bin.000110[[email protected]_test_dbm1_121_62 load_binlog]# 看到輸出結果是沒有.zip的檔案名稱mysql-bin.000110------------------------------------------------有些指令碼要根據檔案名稱進行各種處理,有時候需要保留檔案名稱拋棄檔案尾碼,也有時候需要檔案尾碼不要檔案名稱,這類提取檔案部分的操作使用shell的內建功能就能實現。需要用到的幾個操作符有:%、%%、#、##。從右向左匹配 :% 和 %% 操作符的樣本#!/bin/bash#提取檔案名稱,刪除尾碼。file_name="text.gif"name=${file_name%.*}echo file name is: $name輸出結果:file name is: test# ${VAR%.* }含義:從$VAR中刪除位元於 % 右側的萬用字元左右匹配的字串,萬用字元從右向左進行匹配。現在給變數 name 賦值,name=text.gif,那麼萬用字元從右向左就會匹配到 .gif,所有從 $VAR 中刪除匹配結果。# % 屬於非貪婪操作符,他是從左右向左匹配最短結果;%% 屬於貪婪操作符,會從右向左匹配合格最長字串。file_name="text.gif.bak.2012"name=${file_name%.*}name2=${file_name%%.*}echo file name is: $nameecho file name is: $name2輸出結果:file name is: test.gif.bak    //使用 %file name is: test            //使用 %%操作符 %% 使用 .* 從右向左貪婪匹配到 .gif.bak.2012從左向右匹配:# 和 ## 操作符樣本#!/bin/bash#提取尾碼,刪除檔案名稱。file_name="text.gif"suffix=${file_name#*.}echo suffix is: $suffix輸出結果:suffix is: gif# ${VAR#*.} 含義:從 $VAR 中刪除位元於 # 右側的萬用字元所匹配的字串,萬用字元是左向右進行匹配。# 跟 % 一樣,# 也有貪婪操作符 ## 。file_name="text.gif.bak.2012.txt"suffix=${file_name#*.}suffix2=${file_name##*.}echo suffix is: $suffixecho suffix is: $suffix2輸出結果:suffix is: text.gif.bak.2012     //使用 #suffix2 is: txt                  //使用 ##操作符 ## 使用 *. 從左向右貪婪匹配到 text.gif.bak.2012樣本2,定義變數 url="www.1987.name"echo ${url%.*}      #移除 .* 所匹配的最右邊的內容。www.1987echo ${url%%.*}     #將從右邊開始一直匹配到最左邊的 *. 移除,貪婪操作符。wwwecho ${url#*.}      #移除 *. 所有匹配的最左邊的內容。1987.nameecho ${url##*.}     #將從左邊開始一直匹配到最右邊的 *. 移除,貪婪操作符。name

ftp上傳下載記錄

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.