How to download Jenkins and Tomcat via shell script
How to download Jenkins and Tomcat via shell script
In this article that how to download Jenkins and Tomcat via shell script with the log. This bash script is very easy and everyone can understand. please let us know if you are facing any issue regarding bash script with function and without function.
Example: 1
There is two function in which you can download both software links but we are using the same URL to download both applications. it's just an example.
#! /bin/bash
jen_url="http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.47/bin/apache-tomcat-8.5.47-windows-x64.zip"
tom_url="http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.47/bin/apache-tomcat-8.5.47-windows-x64.zip"
log_file="jen_tom_download.log"
download_jenkins(){
echo "Downloading Jenkins" | tee -a $log_file
wget $jen_url
if [ $? -eq 0 ]
then
echo "Successfully download jenkins" | tee -a $log_file
else
echo "Jenkins download is failed. Please check it manually" | tee -a $log_file #or >>$log_file
fi
}
download_tomcat(){
echo "Downloading Tomcat" | tee -a $log_file
wget $tom_url
if [ $? -eq 0 ]
then
echo "Successfully download Tomcat" | tee -a $log_file
else
echo "Tomcat download is failed. Please check it manually" | tee -a $log_file
fi
}
download_tomcat
download_jenkins
Example: 2
There is a single function in which you can download both software links but we are using same URL to download both applications. it's just an example.
#! /bin/bash
jen_url="http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.47/bin/apache-tomcat-8.5.47-windows-x64.zip"
tom_url="http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.47/bin/apache-tomcat-8.5.47-windows-x64.zip"
download_url(){
app_name=$1
req_url=$2
echo "Downloading $app_name"
wget $req_url
if [ $? -eq 0 ]
then
echo "Successfully download $app_name"
else
echo "$app_name download is failed. Please check it manually"
fi
}
download_url jenkins $jen_url
download_url tomcat $tom_url
0 comments
Please leave your comments...... Thanks