Using the shell to test the download under Linux, the code is as follows:
Copy Code code as follows:
#!/bin/bash
#date: 20140210
#used for test server download speed
R_host= "188.18.28.19"
R_dir= "/home/test0208/tmp"
r_file= "$r _dir/ddfile2m"
L_dir= "/home/yangjuying/tmp"
l_file= "$l _dir/ddfile2m"
l_log= "$l _dir/182.18.28.19-download.log"
echo "----------$ (date +%y%m%d-%h%m%s)----------" >> $l _log
Start_t= "$ (date +%s)"
Scp-p22-o connecttimeout=10-o gssapiauthentication=no test0208@ $r _host: $r _file $l _file >> $l _log 2>&1
Rc= "$?"
If ["$RC"-eq 0];then
Stop_t= "$ (date +%s)"
File_stat= "$ (stat $l _file)"
File_ctime= "$ (echo" $file _stat "| awk-f" [.] " ' Fnr==5{print $2,$3} ' | Sed ' s/[-:]//g ') "
File_ct= "$ (awk-v t=" $file _ctime "' Begin{print mktime (t)} ')"
File_size= "$ (du-sm $l _file | cut-f1)"
RM "$l _file"
Else
Stop_t= ""
Fi
If [-N "$stop _t"];then
connect_t=$ (($file _ct-$start _t))
transfer_t=$ (($stop _t-$file _ct))
all_t=$ (($stop _t-$start _t))
Speed= "$ (echo" scale=3; $file _size/$transfer _t "| BC)"
echo "SIZE:${FILE_SIZE}MB, All_time: $all _t, Connect_time: $connect _t, Transfer_time: $transfer _t, speed:${speed}mb/s" >> $l _log
Else
echo "SCP error!" >> $l _log
Fi