A shell script to test download speed _linux shell

Source: Internet
Author: User

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

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.