33 Perl 指令碼實戰 rscpdown

2021-09-23 10:31:25 字數 1358 閱讀 9184

$ rscpdown 127.0.0.1 zongf gaofeng . /etc/group

group

$ rscpdown 127.0.0.1 zongf gaofeng . /etc/pass* /usr/bin/expect

passwd 100% 2488 4.5mb/s 00:00 eta

#!/usr/bin/perl

#args: 遠端伺服器ip, 使用者名稱, 密碼, 本地資料夾, 遠端檔名列表, [expect 命令絕對路徑]

#auth: zonggf

#date: 2017-07-11

use term:

:ansicolor qw(:constants)

;$term::ansicolor::autoreset=1

;#檢查是否是查詢幫助

sub check_help

#判斷傳入引數個數if(

@ar**

<5)

elsif

(@ar**

>5)

}#################### 主程式 ####################

#校驗幫助

&check_help

;#設定預設命令

$expect

="expect"

;#獲取指令碼傳入的ip, 使用者名稱, 密碼

($ip

,$user

,$password

,$local_dir

,$remote_files)=

@ar**

;#拼接expect命令

$cmd

="$expect -c 'spawn scp $user\@$ip:$remote_files $local_dir \n"

."expect '

."\n"

."\"*password:*\" \n"

."}\n"

."interact\n"

."exit\n"

."'"

;# 執行命令

@files

=`$cmd`

;# 處理返回結果

$flag=0

;for

my$el

(@files

)elsif

($flag==1

)}#處理返回結果

unless

($#results==0

&&$results[0

]=~/cannot access/)}

}

oracle資料庫匯出匯入 perl指令碼實現

匯出oracle資料庫 usr bin perl w set nls lang american america.al32utf8 my aa exp system dbname file d daochu.dmp owner cm foreach aa print print oracle dat...

perl 測試指令碼

修改日期 2010年01月09日 1.系統環境 系統版本 fedora6 x86 64 db2版本 db2 v9.5.0.3 perl版本 v5.8.8 系統自帶 perl dbi版本 perl dbi 1.52 1.fc6 系統自帶 dbd db2版本 dbd db2 1.76 2.安裝dbd d...

perl指令碼練習

題目 12 34 56 78 24 65 87 90 76 11 67 87 100 89 78 99 求出文字中數字的最大 小值 我看很多的朋友都用shell的awk實現了,但本人對awk不是很了解,試著用perl簡單的寫了一下,也能實現 code usr bin perl w use stric...