07-02-2008
for loop sytax error
Hello folks,
I am relatively new to UNIX shell scripting but I have just written this small for loop script below:
var="100 300"
for ctr in ${var}
do
echo "$ctr --- $var"
done
exit 0
But when I am running the script I am getting the error below:
' unexpected: syntax error at line 4 : `do
Thanks a lot.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
Working on AIX using the following for loop.
for a in `find /edi/iTracTEST/sessions -name nohup.out -print`
do
echo $a
done
On the command line it works fine, but insert the code in a file and then running it, it does not want to work. I get the following back.
' is not... (3 Replies)
Discussion started by: hugow
3 Replies
2. HP-UX
I'm adding additional route on hpux 11.22 and syntax seems to be wrong to me. However the application works and everything else.
Old systax in netconf file.
LANCONFIG_ARGS=ether
ROUTE_GATEWAY=xxx.xx.xx.xx
ROUTE_COUNT=1
ROUTE_DESTINATION=default
Note: There are no double Quotations? is this... (0 Replies)
Discussion started by: catwomen
0 Replies
3. Shell Programming and Scripting
hi friends,
i wrote one simple shell script.. in that am using for loop... when i am trying to execute the script.it shows syntax error at for loop line '((' unexpected.
#!/bin/ksh
##
##### To find no of files in the directory
NOF=`ls -l /root/COMM/LOGS/eds/20081025| wc -l`... (5 Replies)
Discussion started by: rdhaprakasam
5 Replies
4. UNIX for Dummies Questions & Answers
Hello all,
I'm a Unix novice for the most part. I have script running in tcsh (bash from the command prompt).
All I'm trying to do is have the script create a file if need be, and if the file exists, exit the script. Here is the coding:
tail -50 /home/redlight/usac.log | grep... (3 Replies)
Discussion started by: sax2groove2
3 Replies
5. Solaris
Hi,
Iam trying to add a while loop in my script in the below way which gets value from count file and checks if its not equal to 0.If yes then it shld echo me a message.
while //count file has some number other than 0
do
echo "count is not zero"
done
But iam getting this error:... (5 Replies)
Discussion started by: jyothi_wipro
5 Replies
6. UNIX for Dummies Questions & Answers
Hi,
I get the following output
98 -1
98 0
./get_AB04-time: line 79: ((: i< && 0 !=7 : syntax error: operand expected (error token is "&& 0 !=7 ")
I have this part of code. Line 79 is the line of the for loop.
echo ${OCCURRENCE} $i_START
CASE=0;
i_END=${i_START}... (4 Replies)
Discussion started by: f_o_555
4 Replies
7. Shell Programming and Scripting
Hello All,
I am having a problem with an “if loop” within a “while loop” in my Korn Shell program. The basic concept of the program is that it searches for the existence of a series of load files in a load directory, and once it finds one of these files, it begins the following process:
· Creates... (4 Replies)
Discussion started by: jonesdk5
4 Replies
8. Shell Programming and Scripting
the program just prints all the command line arguments
Getting error in the program
error
./hellow: line 13: 0: command not found
./hellow: line 13: 0: command not found
below is the program
#!/bin/bash
num=$#
echo $num
if
then
echo "No arguments are passed ."
else
... (7 Replies)
Discussion started by: BHASKARREDDY006
7 Replies
9. Shell Programming and Scripting
Hi All,
while executing this code ,I'm gettign below Error
if_test: line 3:
#!/bin/bash
if ;
then
echo "this is aginity;"
elif ;
then
echo "this is informatica;"
fi
exit (3 Replies)
Discussion started by: netdbaind
3 Replies
10. Shell Programming and Scripting
This is my first ever bash script. What i wish to achieve is to find all files in current directory except the script file and count lines in each found file. Some thing seems to be wrong with the if statement :confused: Please help why it does not work? and maybe you have some ideas how to improve... (3 Replies)
Discussion started by: chinababy
3 Replies
LEARN ABOUT CENTOS
escape
escape(1) Mail Avenger 0.8.3 escape(1)
NAME
escape - escape shell special characters in a string
SYNOPSIS
escape string
DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result.
EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string:
$ var='; echo gotcha!'
$ eval echo hi $var
hi
gotcha!
$
Using escape, one can avoid executing the contents of $var:
$ eval echo hi `escape "$var"`
hi ; echo gotcha!
$
A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For
example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient:
#!/bin/sh
formail -x to -x cc -x resent-to -x resent-cc
| fgrep "$1" > /dev/null
&& exit 0
echo "<$1>.. address does not accept blind carbon copies"
exit 100
To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt
script:
bodytest reject_bcc `escape "$RECIPIENT"`
SEE ALSO
avenger(1),
The Mail Avenger home page: <http://www.mailavenger.org/>.
BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells.
AUTHOR
David Mazieres
Mail Avenger 0.8.3 2012-04-05 escape(1)