This document discusses scripting in Linux. It covers creating and running scripts, basic script architecture including shebang lines and variables, commands like echo, read, and conditional and loop structures. Examples provided include a login validation script, calculator script, and modified calculator with division error handling, and concept of a phonebook script.
Best training-in-mumbai-shell scriptingvibrantuser
Vibrant Technologies is headquarted in Mumbai,India.We are the best Shell Scripting training provider in Navi Mumbai who provides Live Projects to students.We provide Corporate Training also.We are Best Shell Scripting classes in Mumbai according to our students and corporators
Best training-in-mumbai-shell scriptingvibrantuser
Vibrant Technologies is headquarted in Mumbai,India.We are the best Shell Scripting training provider in Navi Mumbai who provides Live Projects to students.We provide Corporate Training also.We are Best Shell Scripting classes in Mumbai according to our students and corporators
Best training-in-mumbai-shell scriptingvibrantuser
A shell script is a text file that contains a sequence of commands for a UNIX-based operating system. It's called a shell script because it combines into a "script" in a single file a sequence of commands that would otherwise have to be presented to the system from a keyboard one at a time. The shell is the operating system's command interpreter and the set of commands you use to communicate with the system. A shell script is usually created for command sequences for which a user has a repeated need. You initiate the sequence of commands in the shell script by simply entering the name of the shell script on a command line.
Why Shell Scripting ?
Shell scripts can take input from a user or file and output them to the screen.
Whenever you find yourself doing the same task over and over again you should use shell scripting, i.e., repetitive task automation.
Creating your own power tools/utilities.
Automating command input or entry.
Customizing administrative tasks.
Creating simple applications.
Since scripts are well tested, the chances of errors are reduced while configuring services or system administration tasks such as adding new users.
Practical examples where shell scripting actively used :
Monitoring your Linux system.
Data backup and creating snapshots.
Dumping Oracle or MySQL database for backup.
Creating email based alert system.
Find out what processes are eating up your system resources.
Find out available and free memory.
Find out all logged in users and what they are doing.
Find out if all necessary network services are running or not. For example if web server failed then send an alert to system administrator via a pager or an email.
Find out all failed login attempt, if login attempt are continue repeatedly from same network IP automatically block all those IPs accessing your network/service via firewall.
User administration as per your own security policies.
Find out information about local or remote servers.
Configure server such as BIND (DNS server) to add zone entries.
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Zyxware Technologies
A workshop on "An introduction to BASH shell scripting". Conducted at CSI Students Convention at TKM College of Engineering, Kollam, Kerala on 15th September, 2012
http://www.zyxware.com/articles/3080/zyxware-conducts-workshop-on-bash-scripting-at-tkm-college-of-engineering-kollam
This presentation is made for beginners who wish to write a simple script and also help those who already working in the sys-admin, support roles to increase their scope for more experiments in different areas where a developer, sys-admin, app-admin, web-admin can use it.
This is a presentation compiled by Mihai Gutuleac, on the topic of "Debugging methods". It presents a list of useful and handy tools and error handler frameworks which will help web developers to easily find out and debug the errors and also to handle more appropriate the raised exceptions in their web applications.
It will provide brief knowledge regarding different types of constructs such as conditional statement execution and looping etc, which is crucial for shell Scripting.
Best training-in-mumbai-shell scriptingvibrantuser
A shell script is a text file that contains a sequence of commands for a UNIX-based operating system. It's called a shell script because it combines into a "script" in a single file a sequence of commands that would otherwise have to be presented to the system from a keyboard one at a time. The shell is the operating system's command interpreter and the set of commands you use to communicate with the system. A shell script is usually created for command sequences for which a user has a repeated need. You initiate the sequence of commands in the shell script by simply entering the name of the shell script on a command line.
Why Shell Scripting ?
Shell scripts can take input from a user or file and output them to the screen.
Whenever you find yourself doing the same task over and over again you should use shell scripting, i.e., repetitive task automation.
Creating your own power tools/utilities.
Automating command input or entry.
Customizing administrative tasks.
Creating simple applications.
Since scripts are well tested, the chances of errors are reduced while configuring services or system administration tasks such as adding new users.
Practical examples where shell scripting actively used :
Monitoring your Linux system.
Data backup and creating snapshots.
Dumping Oracle or MySQL database for backup.
Creating email based alert system.
Find out what processes are eating up your system resources.
Find out available and free memory.
Find out all logged in users and what they are doing.
Find out if all necessary network services are running or not. For example if web server failed then send an alert to system administrator via a pager or an email.
Find out all failed login attempt, if login attempt are continue repeatedly from same network IP automatically block all those IPs accessing your network/service via firewall.
User administration as per your own security policies.
Find out information about local or remote servers.
Configure server such as BIND (DNS server) to add zone entries.
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Zyxware Technologies
A workshop on "An introduction to BASH shell scripting". Conducted at CSI Students Convention at TKM College of Engineering, Kollam, Kerala on 15th September, 2012
http://www.zyxware.com/articles/3080/zyxware-conducts-workshop-on-bash-scripting-at-tkm-college-of-engineering-kollam
This presentation is made for beginners who wish to write a simple script and also help those who already working in the sys-admin, support roles to increase their scope for more experiments in different areas where a developer, sys-admin, app-admin, web-admin can use it.
This is a presentation compiled by Mihai Gutuleac, on the topic of "Debugging methods". It presents a list of useful and handy tools and error handler frameworks which will help web developers to easily find out and debug the errors and also to handle more appropriate the raised exceptions in their web applications.
It will provide brief knowledge regarding different types of constructs such as conditional statement execution and looping etc, which is crucial for shell Scripting.
Yocto - Embedded Linux Distribution MakerSherif Mousa
Yocto is an Embedded Linux distribution maker.
This presentation is a quick start guide for Yocto buildsystem to get familiar with the tool and how to start building your own custom Linux system for a specific hardware target.
In a presentation for Atainz, Terry Baucher of Baucher Consulting (www.baucherconsulting.co.nz) explains how to handle an IRD Audit & what to do should the IRD come calling.
Baucher also goes into detail about the difference between an IRD Audit and an IRD Review and how each should be treated.
This presentation was given on behalf of Atainz in March 2013
The Raspberry Pi is a series of credit card–sized single-board computers developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools.
The original Raspberry Pi and Raspberry Pi 2 are manufactured in several board configurations through licensed manufacturing agreements with Newark element14 (Premier Farnell), RS Components and Egoman. These companies sell the Raspberry Pi online. Egoman produces a version for distribution solely in China and Taiwan, which can be distinguished from other Pis by their red colouring and lack of FCC/CE marks. The hardware is the same across all manufacturers.
The original Raspberry Pi is based on the Broadcom BCM2835 system on a chip (SoC), which includes an ARM1176JZF-S 700 MHz processor, VideoCore IV GPU, and was originally shipped with 256 megabytes of RAM, later upgraded (models B and B+) to 512 MB. The system has Secure Digital (SD) (models A and B) or MicroSD (models A+ and B+) sockets for boot media and persistent storage.
Variable interpolation is a standard way to BASH your head. This talk looks at interpolation, eval, ${} handling and "set -vx" to debug basic variable handling.
Full-day tutorial for the dutch php conference 2011 giving a very quick tour around all the various areas of the ZCE syllabus and some tips on the exam styles
A set of rules and best practices to write bash shell scripts. Following these rules, you will have less programming errors and spend less time debugging.
It also shows and explains a lot of features from bash you didn't event know existed :
Pattern removal: ${var##*/}
StrReplace: ${var//search/replace}
Options: set -o pipefail -o nounset -o noclobber
And many more...
1. SHATRIX
Scripting
A Creating and Running Scripts
Basic Script Architecture
G echo
E Variables
N read
Conditional statements
D Loops
A Examples
2. Creating and Running Scripts
Scripts are normal text files with x permission
touch scriptname
chmod 777 scriptname
chmod u+x scriptname
To run a script:
full path
./scriptname
sh scriptname
bash scriptname
3. Basic Script Architecure
#!(shell-path) #!/bin/bash
variables definition echo ”Welcome”
read var1
read variables from user echo $var1
loops
conditional statements
print output to terminal
pipe & redirection to other files
4. echo
echo displays a line of text
echo ”string”
echo $variablename
echo ”string $varname”
echo ”string $varname anotherstring”
echo $(command)
echo ”Welcome Linux users”
5. Variables
Define a variable
variablename=VALUE
Print a variable to screen
echo $variablename
System variables:
Normal: has to be changed with each user
HOME PWD SHELL
Environmental: changes with the login shell only
login shell with (su )
PATH
env
6. read
read take a value from the user to a variable
read variablename
read p ”string” variablename
read p ”Enter your name” name
echo ”Your name is $name”
7. Conditional Statements
if statement #!/bin/bash
if [ condition ] x=5
if [ $x = 5 ]
then
then
things to do echo ”right”
elif [ anothercond. ] else
echo ”wrong”
then fi
things to do
else
things to do
fi
8. Conditional Statements
case statement
#!/bin/bash
case $variablename in x=5
value_1) case $x in
things to do;; 4)
echo ”x=4”;;
value_2) 5)
things to do;; echo ”x=5”
echo ”ok”;;
*)
*)
default action;; echo ”I don't know”;;
esac esac
9. Loops
for loop
for VARIABLE in ARRAY
do
things on each value
done
#!/bin/bash
for i in 1 2 3 4 5
do
echo ”current value is $i”
done
10. Loops
while loop
while [ condition ]
do
#!/bin/bash
things to do
VAR=0
done while [ $VAR lt 3 ]; do
echo $VAR
VAR=$[$VAR+1]
equal (=) done
not equal (!=)
Less than (lt)
Greater than (gt)
11. Examples (User Login)
#!/bin/bash
user_name="shatrix"
password="13"
read p "User Name: " login_name
stty echo
read p "Password: " login_pass
stty echo
echo ""
if [ $login_name = $user_name ]; then
if [ $login_pass = $password ]; then
echo "Now you are logged in....."
else
echo "Error, wrong password, try again"
fi
else
echo "Error, user name doesn't exist"
fi
12. Examples (Calculator)
#!/bin/bash
read p "Enter First Number: " f_num
read p "Enter Second Number: " s_num
read p "Enter Operation: " op
case $op in
+)
echo "$f_num + $s_num = $[$f_num+$s_num]";;
)
echo "$f_num $s_num = $[$f_num$s_num]";;
x)
echo "$f_num x $s_num = $[$f_num*$s_num]";;
/)
echo "$f_num / $s_num = $[$f_num/$s_num]";;
esac
13. Examples (Modified Calculator)
#!/bin/bash
read p "Enter First Number: " f_num
read p "Enter Second Number: " s_num
read p "Enter Operation: " op
case $op in
+)
echo "$f_num + $s_num = $[$f_num+$s_num]";;
)
echo "$f_num $s_num = $[$f_num$s_num]";;
x)
echo "$f_num x $s_num = $[$f_num*$s_num]";;
/)
if [ $s_num != 0 ]; then
echo "$f_num / $s_num = $[$f_num/$s_num]"
else
echo "Error, division by zero"
fi;;
*)
echo "Wrong operation, please try again !!!"
esac