for:badly formed number


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting for:badly formed number
# 1  
Old 06-05-2008
for:badly formed number

Hi,
I am doing the following but it complains and says "for:badly formed number"
does anyone know why?

#!/bin/tcsh
foreach(....)
............

set depth=64
set width=23
if ($depth==64) then
echo "if"
set addr_bits=5
else
echo "else"
endif

echo "addr_bits:$addr_bits"
echo "depth:$depth"
echo "width:$width"

end


Guys please note that i need to use #!/bin/tsch because foreach will not work without it. becuase the if statement works fine just the way it is if i don't use #!/bin/tsch and i do the following
depth=64
if ($depth==64) then
echo "if"
addr_bits=5
else
echo "else"
endif

the problem occurs when i use #!/bin/tcsh
# 2  
Old 06-05-2008
i) please use the code markup tag and indention for better readability
ii) there's no single for in your snippet which depends on numbers
iii) it would be interesting to know what's inside foreach(...)
# 3  
Old 06-05-2008
here is the actual code. note that testing1 consist of couple of line lets say asdaskljl64x3sdfsd is the first line of the testing1 file
#!/bin/tcsh
foreach filename (`cat testing1`)
set string=$filename
set depth=`echo "$string" | sed -e 's/^[^0-9]*\([0-9][0-9]*\).*/\1/'`
set width=`echo "$string" | sed -e 's/.*\([0-9][0-9]*\)[^0-9]*$/\1/'`

if ($depth==64) then

set addr_bits=5
endif

echo "addr_bits:$addr_bits"
echo "depth:$depth"
echo "width:$width"

end
# 4  
Old 06-05-2008
error message does (in my eyes, generally I don't use ksh) not match the code.

Only point that matches numbers in any way:

However: Bourne-comment (mostly be the same on ksh): use
Code:
if ( "$depth" -eq "64") then

instead of
Code:
if ($depth==64) then

-eq => numerical comparison
"" => prevents problems when $depth is empty
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Badly placed ()'s

Edit - I don't know how to delete posts. The question I asked here ended up not being the question I should have asked as I didn't realise I needed to edit my script to comply with SGE. Hi, My script is: #!/bin/bash # Perform fastqc on files in a specified directory. for ((j=1;... (8 Replies)
Discussion started by: una1992
8 Replies

2. Programming

Badly places ()'s on C

I dont know why this Linux would give me badly placed () error all the time for this; #include <stdio.h> int main() { register int num=0 ; while ((num < 5)) ++num; printf("Pass %d \n", num) ; return 0 ; } can anyone help me please? (11 Replies)
Discussion started by: sizzler786
11 Replies

3. Shell Programming and Scripting

Badly Placed ()'s when trying to use csh

The terminal is bash. Whenever I try to execute csh just by itself it gives Badly Placed ()'s. Whenever I try to use csh with a script it also gives Badly Placed ()'s. My script is this, there is nothing wrong with it, since it used by other students in class as well. (I have also asked... (5 Replies)
Discussion started by: quantumizer
5 Replies

4. Shell Programming and Scripting

tcsh: not run script (if: Badly formed number)

Hello I have Linux Debian & tcsh shell. My mini script not run :(. Startup script displays a message: user@host:dir% ./test if: Badly formed number. script: #!/bin/tcsh -f #script check size files systems set x = `df -h /usr | tail -n1 | awk '{ print( $5 ); }'` set y = 60% if ($x... (5 Replies)
Discussion started by: moskovets
5 Replies

5. Shell Programming and Scripting

history: Badly formed number

% history clean history: Badly formed number. :( % echo $0 /usr/local/bin/tcsh % uname SunOS % grep -e "hist" .tcshrc.user set history=90 set savehist=80 Please suggest what could be the problem here. Thanks in advance. (1 Reply)
Discussion started by: mayankmehta_83
1 Replies

6. Shell Programming and Scripting

Unix XML Parsing check well formed

Hi, I am using ksh, is there any command which can check whether the XML file is well formed or not? Regards, Sreejit (1 Reply)
Discussion started by: sreejitnair123
1 Replies

7. Shell Programming and Scripting

badly placed ()'s

i'm trying to run the following program but i keep getting the message "badly placed ()'s" can u help? #include "modularity_mat.h" #include "../sparse_mlpl/sparse_matrix.h" adj_matrix_arr* allocate_mem_for_matrix_arr (int y) { /* Create the adj matrix and allocate memory */ ... (2 Replies)
Discussion started by: ronirosner
2 Replies

8. UNIX for Dummies Questions & Answers

Need Help Badly: Newbie Here

I have this file: NPANXX|BILLDATE|DIVCODE|COMID|RAO|LIKECODE|BOSS|SORD|STATECODE| 087001|BP01|H|SWBT| |041|IMR6|IMSR6|AR| 087002|BP03|H|SWBT| |042|IMR6|IMSR6|AR| 087003|BP05|H|SWBT| |043|IMR6|IMSR6|AR| .... these are the things that i HAve to do: Insert a new column named “TEST” All... (14 Replies)
Discussion started by: arkhei
14 Replies

9. Shell Programming and Scripting

Badly formed number.

I have the following script running every day numerous times a day and it works fine, but very occasionally I get the following error if: Badly formed number. Anyone know why? Here is the script that runs with the follow parms LCTMDBSE 100000 130000 160000 #!/bin/csh ... (0 Replies)
Discussion started by: Northerner
0 Replies

10. Shell Programming and Scripting

Badly placed ()'s. - error

Hi, when I execute the below script, I am getting following error "Badly placed ()'s". can anyone please help me fix ---------------------------------------------------------- # Usage: ani -n -a -s -w -d # # # help_ani() To print help # help_ani() { echo "Usage: $0 -n -a -s -w -d"... (3 Replies)
Discussion started by: amitrajvarma
3 Replies
Login or Register to Ask a Question