I'm new to bash scripts and I'd like to make a simple progressbar
init pb
do stuff
pb add 10%
do other stuff
...
But, the scripts that'll lunch will print some log, and I don't want the progress bar to disappear, I'd like it to stay at the bottom of the screen. Is that possible ?
thanks a lot,
Arthur
Here is my code :
#!/bin/bash
echo 'Welcome to autoIrc'
echo 'This will automaticly create a gephi file for you'
echo 'I suggest running the script in a screen if you are with ssh'
# Are you sure ?
location=`pwd`
echo "We are in $location. Do you want to install the script there ? [Y/n]"
read -p 'Y/n >' confirm
if [ $confirm != "Y" ]
then
echo "I am exiting"
exit
fi
clear
echo 'Cleaning up...'
echo -e "\e[100m"
echo "We are in $location."
echo "Files list here:"
echo `ls ./`
echo "File list in ../"
echo `ls ../`
rm ./ircsnapshot -R
echo -e "\e[49m"
clear
# Okay, now, go on
echo 'First, a bit of config'
read -p "Please enter the bot nickname >" nickname
read -p "Please enter the bot username >" username
read -p "Please enter the bot realname >" realname
read -p "Now, please enter the number of seconds between commands >" throttle
read -p "Please enter the server adress >" server
# Git, python, toilet
echo 'Downloading dependencies. You may have to enter your SU password.'
echo -e "\e[100m"
sudo apt-get update -y && apt-get install -y git python toilet
echo -e "\e[49m"
clear
echo 'Dependencies are now installed.'
# Main script
echo 'Cloning the script from github to here'
echo -e "\e[100m"
git clone https://github.com/bwall/ircsnapshot.git
echo -e "\e[49m"
cd "./ircsnapshot/ircsnapshot"
location=`pwd`
echo "We are in $location."
echo "Files list here:"
echo `ls ./`
echo "File list in ../"
echo `ls ../`
echo -e "\e[41m"
rm ./example.png
echo -e "\e[49m"
clear
# GeoIP data
echo "I will download the database"
echo -e "\e[100m"
wget -O geolite.zip http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/GeoLiteCity-latest.zip
echo -e "\e[49m"
clear
echo 'Download complete. Unzipping'
echo -e "\e[100m"
unzip geolite.zip -d ./GeoLiteData
echo -e "\e[49m"
mv ./GeoLiteData/*/* ./GeoLiteData
clear
echo "Is it OK ?"
ping -c 1 $server
# script
clear
echo "We are in $location."
echo "Files list here:"
echo `ls ./`
echo "File list in ../"
echo `ls ../`
echo "I will lunch the script now It will print some lines and take some time'"
echo -e "\e[100m"
python "./ircsnapshot.py" "-n $nickname" "-u $username" "-r $realname" "$server"
echo -e "\e[49m"
# 2nd script
echo 'Great !'
clear
echo "I'll now convert the json generated to something readable by gephi"
echo "This will take some time"
echo -e "\e[100m"
sudo chmod +x ./to.gexf.py
var=$(./to.gexf.py -m "./GeoLiteData" "UserToLink" "./$server.json")
echo -e "\e[49m"
clear
echo 'Good.'
gexf="./$server.gexf"
echo "$var" >> "$gexf"
echo "Here it is : ./ircsnapshot/ircsnapshot/$gexf"
toilet -t --filter gay Finished install !
exit
EDIT : The "duplicate" does not show a progress bar that stays at the bottom of the screen