Download Week 5

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
GNU Compiler Collection (GCC)
and GNU C compiler (gcc)
• tools used to compile programs in Linux
Hello World! program compilation
in C
•
•
•
•
•
#include <stdio.h>
int main()
{
printf("hello world!\n");
}
PERL, Python, and bash—script
interpreters in Linux
• Python is for rapid GUI development
• PERL is for complex jobs and Web pages
• bash is for everyday, general-purpose
scripting.
Control structures used to develop
scripting logic
•
•
•
•
If...Then...Else statements
Case statements
For loops
While loops
• table on page 907
BASH Scripting
• Shell scripting provides a way to automate
everyday tasks into much simpler commands.
– For example, to add 200 users would require
running the useradd command 200 times.
• The first line of a script identifies the shell or
interpreter used to run this script.
– Linux uses BASH as the default shell so
#! /bin/bash is the first line of BASH scripts.
• Any line with a # sign is a comment line.
– Use comments to document what a script is
doing.
• BASH scripting is basically taking several
commands into one file in the sequence
you wish them executed.
• The read statement reads the value of a
variable from stdin (standard input).
– It fetches input from the keyboard or a source
redirected to it.
• read a will read a single value from stdin
• read a b c will read multiple values on a single line from
stdin.
• You don’t have to declare variables, just use
them
– VAR1 = 2
– VAR2 = “Hello, World”
•
• Any arguments to the script are numbered
$1, $2, $3, etc and used in the script by
their numbers
• The echo line displays values.
– It can display text: echo “Hello, world”
– It can display the contents of a variable: echo
VAR1
pg905
Lab5.2
Pg911
Pg 929
Lab 5.4
pg919 ex.
Pg 921
Lab 5.5
The Read command
• the Read command will be used with the
While loop to take input from a file. This
requires the use of the standard input
redirector.
Pg 956