Tuesday 5 May 2020

A simple animation bash script

Animation bash script

$ cat frame1

    =========
  =                  =
 =      -     -      =
 =         ^         =
 =         -         =
   \_________/
           ##
         ####
        # ## #
           | |
         _| |_

$ cat frame2

    =========
  =                  =
 =      o     o     =
 =         ^         =
 =         -        =
   \_________/
           ##
         ####
        # ## #
           | |
         _| |_

$ cat frame3

    =========
  =                  =
 =      0     0     =
 =         ^         =
 =      @@@      =
   \_________/
           ##
         ####
        # ## #
           | |
         _| |_

$ cat animation.sh
for ((i; i<=10; i++))
do

clear
cat frame1
sleep .5
clear
cat frame2
sleep .1
clear
cat frame3
sleep .5
done

$ chmod +x animation.sh
$ ./animation.sh



Sunday 3 May 2020

Bash scrip to check internet speed frequently in Linux

Check internet speed frequently

$ crontab -l
   # set frequency
   20,50 * * * * sh /usr/local/src/internet_speed_test.sh

$ vim internet_speed.sh
   #!/bin/bash
   # run python to get speed
   python speedtest.py > /var/log/speed_test.log

   # process speed_test.log file
   date=$(date "+%d %B %Y %H:%M")
   echo -n "$date" >> /var/log/speed.log
 
   while IFS= read -r line
   do
     if [[ "$line" == *"Download"* ]] || [[ \n\t"$line" == *"Upload"* ]] ; then
           echo -n  '   ' "$line" >> /var/log/speed.log
     fi
   done < /var/log/speed_test.log
 
   echo -e "\n" >> /var/log/speed.log'

$ tail -f /var/log/speed.log
   03 May 2020 18:05    Download: 9.40 Mbit/s    Upload: 6.34 Mbit/s
   03 May 2020 18:22    Download: 11.34 Mbit/s    Upload: 6.12 Mbit/s

Friday 1 May 2020

Internet Speed Test in Linux Terminal

speedtest using python and fast

  python
$ python3 --version
  Python 3.8.2
$ cat /etc/redhat-release
  CentOS Linux release 7.7.1908 (Core)

$ git clone https://github.com/jpmolekunnel/Speed.git
$ cd Speed/
$ python speedtest.py
  Retrieving speedtest.net configuration...
  Testing from Comcast Cable (71.214.251.133)...
  Retrieving speedtest.net server list...
  Selecting best server based on ping...
  Hosted by Sprint (Fairfax, SC) [114.89 km]: 75.946 ms
  Testing download speed................................................................................
  Download: 8.19 Mbit/s
  Testing upload speed.....................................................................................................
  .Upload: 5.94 Mbit/s

  fast
$ wget https://github.com/ddo/fast/releases/download/v0.0.4/fast_linux_amd64 -O fast
$ chmod +x fast
$ ./fast
   -> 11.64 Mbps

Ref:- addictivetips.com tecmint.com