OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Syntactic Errors

One general class of errors is syntactic. Syntactic errors involve mistyping some element of shell syntax. In most cases, the shell will refuse to execute a script containing this type of error.

In the following discussions, we will use this script to demonstrate common types of er- rors:



#!/bin/bash


# trouble: script to demonstrate common errors number=1

if [ $number = 1 ]; then

echo "Number is equal to 1." else

echo "Number is not equal to 1."

fi

#!/bin/bash


# trouble: script to demonstrate common errors number=1

if [ $number = 1 ]; then

echo "Number is equal to 1." else

echo "Number is not equal to 1."

fi


As written, this script runs successfully:



[me@linuxbox ~]$ trouble

Number is equal to 1.

[me@linuxbox ~]$ trouble

Number is equal to 1.


 

Top OS Cloud Computing at OnWorks: