Hi,
I am new to shell scripting, bash specifically.
I am trying to run the following script:
Code:
#!/bin/bash
#send notification emails
sendMails(){
emails=$1 # get all email ids
}
processLine(){
line="$@" # get all args
echo -e "****************************"
}
# Shell script utility to read a file line line.
# Once line is read it can be process in processLine() function
# You can call script as follows, to read myfile.txt:
# ./readline myfile.txt
# Following example will read line from standard input device aka keyboard:
# ./readline
# -----------------------------------------------
# Copyright (c) 2005 nixCraft <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
### Main script stars here ###
# Store file name
FILE=""
# Make sure we get file name as command line argument
# Else read it from standard input device
if [ "$1" == "" ]; then
FILE="/dev/stdin"
else
FILE="$1"
# make sure file exist and readable
if [ ! -f $FILE ]; then
echo "$FILE : does not exists"
exit 1
elif [ ! -r $FILE ]; then
echo "$FILE: can not read"
exit 2
fi
fi
# read $FILE using the file descriptors
# Set loop separator to end of line
BAKIFS=$IFS
IFS=$(echo -en "\n\b")
exec 3<&0
exec 0<$FILE
while read line
do
# use $line variable to process line in processLine() function
processLine $line
done
exec 0<&3
# restore $IFS which was used to determine what the field separators are
BAKIFS=$ORIGIFS
exit 0
When trying to execute I always get this error:
Code:
'iors_response.sh: line 4: syntax error near unexpected token `{
'iors_response.sh: line 4: `sendMails(){
In case you need to know the permissions. Here is it:
Code:
-rwxr-xr-x 1 abdelraouf users 5224 Mar 4 06:46 biors_response.sh
I run the script using the following command:
Code:
bash biors_response.sh hosts.txt
That's all. If you need any aditional information, please ask.
Thanks in advance.