Topic 2: Logname, Date Time, Shell Script #Linux/Unix: Shell Programming – 001

bash-3.2$ cat firstscript.sh
#!/bin/sh
#clear
echo “SCRIPT BEGINS”
echo “Hello $LOGNAME!”
echo
echo “Today’s date and time: c”
date
echo
mynum=21
myday=”Monday”
echo “The value of mynum is $mynum”
echo “The value of myday is $myday”
echo
echo “SCRIPT FINISHED!!”
echo
bash-3.2$ ./firstscript.sh
SCRIPT BEGINS
Hello shell!

Today’s date and time: Fri Apr 27 08:51:53 EDT 2018

The value of mynum is 21
The value of myday is Monday

SCRIPT FINISHED!!

From: http://sitestree.com/?p=12213
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-29 23:55:03

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Korn Shell Example: Show Dates #Linux/Unix: Shell Programming – 001

bash-3.2$ cat echoscript2.ksh
#!/bin/ksh
#clear
print “SCRIPT BEGINS”
print “Hello $LOGNAME”
print
print -n “Todays date is: ”
date ‘+%m/%d/%y’
print -n “and the current time is: ”
date ‘+%H:%M:%S%n’
print “Now a list of the processes in the current
shell”
ps
print “SCRIPT FINISHED!!”

bash-3.2$ ./echoscript2.ksh
SCRIPT BEGINS
Hello shell

Todays date is: 04/27/18
and the current time is: 08:05:20

Now a list of the processes in the current
shell
PID TTY TIME CMD
18641 syscon 0:00 ps
18585 syscon 0:00 sh
18638 syscon 0:00 echoscri
18589 syscon 0:00 bash
SCRIPT FINISHED!!

From: http://sitestree.com/?p=12210
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-28 23:08:39

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Topic 1: Basic Date Displaying Shell Script #Linux/Unix: Shell Programming – 001

bash-3.2$ cat echoscript1.sh
#!/bin/sh
#clear
echo “SCRIPT BEGINS”
echo “Hello $LOGNAME”
echo
echo “Todays date is: c”
date ‘+%m/%d/%y’
echo “and the current time is: c”
date ‘+%H:%M:%S%n’
echo “Now a list of the processes in the current shell”
ps
echo “SCRIPT FINISHED!!”
bash-3.2$ ./echoscript1.sh
SCRIPT BEGINS
Hello shell

Todays date is: 04/27/18
and the current time is: 07:58:45

Now a list of the processes in the current shell
PID TTY TIME CMD
18612 syscon 0:00 ps
18585 syscon 0:00 sh
18609 syscon 0:00 echoscri
18589 syscon 0:00 bash
SCRIPT FINISHED!! From: http://sitestree.com/?p=12208
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-27 23:03:01

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

If then else example in Shell Programming #Linux/Unix: Shell Programming – 001

#!/bin/sh

#If then else example
#if elif else

NOF=5

if [ $NOF -eq 27 ]

then

echo “No of files and directories = 27”

elif [ $NOF -gt 27 ]

then

echo “No of files are dir are greator than 27”

else

echo “No of files and directories are less than 27”

fi

exit From: http://sitestree.com/?p=12201
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-16 19:47:32

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

On Thursday and Friday tar all contents of /etc folder into /export/home/shell/test/etc.tar .. do misc logs #Linux/Unix: Shell Programming – 001

#!/bin/ksh

# on every thursday and friday tar all contents of /etc folder into /export/home/shell/test/. On thursday only create a log file with the list of files
#in the tar file. On thursday untar /export/home/shell/test/etc.tar into vfstab . Then log vfstab exist or not information

DAY=`date +%a`
DATESTAMP=`date +%m-%d-%Y-%H:%M`

if [[ “$DAY” == Mon ]]
then

echo “Today is Monday”

elif [[ “$DAY” == Tue ]]
then

echo “Today is Tuesday”

elif [[ “$DAY” == Wed ]]
then

echo “Today is Wednesday”

elif [[ “$DAY” == Thu ]]
then

echo “Today is Thursday” >> /export/home/shell/test/log/backup-$DATESTAMP.log
cd /etc
tar cvf /export/home/shell/test/etc.tar * >> /export/home/shell/test/log/backup-$DATESTAMP.log
cd /export/home/shell/test
tar xvf etc.tar vfstab

if [[ -f vfstab ]]
then
echo “file vfstab exist” >> /export/home/shell/test/log/backup-$DATESTAMP.log
else
echo “file vfstab does not exist” >> /export/home/shell/test/log/backup-$DATESTAMP.log
fi

elif [[ “$DAY” == Fri ]]
then

echo “Today is Friday”
cd /etc
tar cvf /export/home/shell/test/etc.tar *

elif [[ “$DAY” == Sat ]]
then
echo “Today is Saturday”

else
echo “Today is Sunday”

fi

exit From: http://sitestree.com/?p=12199
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-16 19:44:31

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

While Loop Example in Shell Programming. Display a Chart #Linux/Unix: Shell Programming – 001

Example Output

bash-3.2$ ./while-loop-example.sh
Enter your Number
10
10 * 1 = 10
10 * 2 = 20
10 * 3 = 30
10 * 4 = 40
10 * 5 = 50
10 * 6 = 60
10 * 7 = 70
10 * 8 = 80
10 * 9 = 90
10 * 10 = 100


The Code

 

#!/bin/ksh

#example : how to use while loop in shell programming

multiplication()
{

#clear
i=1
while (( i <= 10 ))
do
echo “$Y * $i = `expr $Y * $i`”
(( i = i + 1 ))
done

}

echo “Enter your Number”
read X

case “$X” in

1)
Y=1
multiplication
;;

2)

Y=2
multiplication
;;

3)

Y=3
multiplication
;;

4)

Y=4
multiplication
;;

5)

Y=5
multiplication
;;

6)

Y=6
multiplication
;;

7)

Y=7
multiplication
;;

8)

Y=8
multiplication
;;

9)

Y=9
multiplication
;;

10)

Y=10
multiplication
;;

esac
exit From: http://sitestree.com/?p=12197
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-16 19:31:36

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

If then else in shell programming. Count the number of files in current directory, and check … #Linux/Unix: Shell Programming – 001

#!/bin/sh

#count the number of files in current directory, and check if the number is equal to or greater than or less than 26

#NOF represents number of files

NOF=`ls -l | wc -l`

if [ $NOF -eq 26 ]
then
echo “No of files and directories is equal to 26”
fi

if [ $NOF -gt 26 ]
then
echo “No of files is greater than 26”
fi

if [ $NOF -lt 26 ]
then
echo “No of files is less than 26”
fi

exit From: http://sitestree.com/?p=12195
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-16 19:23:07

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Log currently running shell processes into a file in every 30 seconds. #Linux/Unix: Shell Programming – 001

#!/bin/sh

#find all currently running shells and create in full listing form for them . Log the data into a file in every 30 secs
# -e means currentl running
# -f means full format output
# sleep takes parameters in seconds

ps -ef | grep shell >> process.log
sleep 30

ps -ef | grep shell >> process.log
sleep 30

ps -ef | grep shell >> process.log
sleep 30 From: http://sitestree.com/?p=12193
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-16 19:08:10

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Another Example of Case and For Loop #Linux/Unix: Shell Programming – 001

Output First

bash-3.2$ ./ksh_case_chart.sh
Enter your Number
9
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90

—-
???

#!/bin/ksh

#example on how to use case and for loop

multi()
{
#clear
for i in 1 2 3 4 5 6 7 8 9 10
do
echo “$Y * $i = `expr $Y * $i`”
done
}

#take a number from the user ( 1..10)
echo “Enter your Number”
read X

case “$X” in

1)
Y=1
multi
;;

2)
Y=2
multi
;;

3)
Y=3
multi
;;

4)
Y=4
multi
;;

5)
Y=5
multi
;;

6)
Y=6
multi
;;

7)
Y=7
multi
;;

8)
Y=8
multi
;;

9)
Y=9
multi
;;

10)
Y=10
multi
;;

esac
exit

—– From: http://sitestree.com/?p=12189
Categories:Linux/Unix: Shell Programming – 001
Tags:
Post Data:2018-04-16 18:48:57

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

#Engineering: #Canada: #Job/Contract/Project: Any #Engineering: #Computer, #Electrical, #Electronics, #Civil, #Chemical, #Mechanical, #Naval, #Biomedical, and misc Engineering

Date Posted:2021-07-12 .Apply yourself, or submit others as candidates; Build a recruitment team to submit others as candidates; submit RFP to be considered for projects in future; Try to become a vendor so that you are asked to submit consultants/resources in future. If these work for you. This list is posted in this blog everyday provided there are new projects under the criteria

  1. engines-turbines-components-and-accessories-10008
  2. Provision of Engineering Services for Watermain and Wastewater Main Improvements in The Town Of Oakville, Wards 1, 2, 3 (PR-3314A & PR-3314B)
  3. prefabricated-structures-10022
  4. DNE1 Stimulus Electrical
  5. architect-and-engineering-services-10048
  6. Engineering Services Tender 2021 & QA for Gravel Crushing
  7. Engineering Services for Intersection Improvement Program
  8. Request for Engineering Services for the Rehabilitation of Acton Island Bridge
  9. P8143 IPD Structural Engineer Consultant – Edmonton Public School Board (EPSB) Solar Initiative: Phase 2
  10. Electrical Review & Back-Up Generator Installation
  11. maintenance-repair-modification-rebuilding-and-installation-of-goods-equipment-10054
  12. Electrical Maintenance & Repair Services, Pictou County, N.S.
  13. operation-of-government-owned-facilities-10039
  14. Engineering Services for Intersection Improvement Program
  15. Owner’s Engineering Services for the Bow River Bridge
  16. research-and-development-r-d-10036
  17. Engineering Services for Intersection Improvement Program
  18. special-studies-and-analysis-not-r-d-10047
  19. Digester 4 Condition Assessment and Feasibility Study from the 20-117 Wastewater Engineering Services Pre-Qualification
  20. Keywords Used:engineer,civil,mechanical,electrical,electronics,mechatronics,naval,biomedical,computer engineer,software engineer,civil engineer,biomedical,electrical engineer,electronics engineer,mechanical engineer,metallurgical,chemical engineer,industrial engineer,communications engineer,quality assurance engineer,Aerospace engineer,aeronautical engineer,Engineering manager,Agricultural Engineer,Automotive Engineer,Environmental Engineer,Geological Engineer,Marine Engineer,Petroleum Engineer,Acoustic Engineer,Acoustic Engineer,Aerospace Engineer,Agricultural Engineer,Applied Engineer,Architectural Engineer,Audio Engineer,Automotive Engineer,Biomedical Engineer,Chemical Engineer,Civil Engineer,Computer Engineer,Electrical Engineer,Environmental Engineer,Industrial Engineer,Marine Engineer,Materials Science Engineer,Mechanical Engineer,Mechatronic Engineer,Mining and Geological Engineer,Molecular Engineer,Nanoengineering,Nuclear Engineer,Petroleum Engineer,Software Engineer,Structural Engineer,Telecommunications Engineer,Thermal Engineer,Transport Engineer,Vehicle Engineer,engineering