syntax error in .csh file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting syntax error in .csh file
# 1  
Old 04-05-2011
syntax error in .csh file

Hi all, I am trying to modify a script for research purposes and am having difficulty here as I have little prior experience with C-shell scripting.


The script looks as follows (it includes tcl commands like runFEP that you can ignore)


Code:
#!/bin/bash

for ((old=1, new=2; old<=4;  old++,new++))
a1=${old}%50
a2=${new}%50
do

cat > input${new}.conf <<EOF
${a1}

.
.
.
.
.
.
.
runFEP ${a1} ${a2} 0.02 \$nSteps ; # 50 windows outward


EOF

done












My question: I keep getting a syntax error when defining my two variables a1 and a2. I essentially need these variables to be
a1 = value of variable old divided by 50
a2 = value of variable new divided by 50


Any help here would be most appreciated!
Thanks

Last edited by pludi; 04-05-2011 at 08:28 AM..
# 2  
Old 04-05-2011
http://www.grymoire.com/Unix/CshTop10.txt

You mentionned C-Shell but your script start with
Code:
#!/bin/bash

Which is Bourn Again SHell : is it a modification that you did or is it from original file ?
# 3  
Old 04-05-2011
a1=`expr ${old} / 50`
# 4  
Old 04-05-2011
Thanks,
but I keep getting the same error

template_inp.sh: line 4: syntax error near unexpected token `a1='expr${old}/50''
template_inp.sh: line 4: `a1='expr${old}/50''
# 5  
Old 04-05-2011
make sure you use ` instead of ' or "
# 6  
Old 04-05-2011
Hi,
Seeing your error, seems you have not put a space between expr and ${old}. Use below command.
a1=`expr $old / 50`
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

IF section problem. syntax error: unexpected end of file error

Hello, I have another problem with my script. Please accept my apologies, but I am really nooby in sh scripts. I am writing it for first time. My script: returned=`tail -50 SapLogs.log | grep -i "Error"` echo $returned if ; then echo "There is no errors in the logs" fi And after... (10 Replies)
Discussion started by: jedzio
10 Replies

2. Shell Programming and Scripting

Unexpected End of File Syntax Error

Hi, I am brand new to this so I apologize ahead of time for any formatting problems. I know there is a previous (closed) thread on here about this problem but I wasn't able to fix the error following the posts there so I thought I could create a new one. Here is the error I am getting: ... (3 Replies)
Discussion started by: SierraG
3 Replies

3. Solaris

Nice syntax in csh on Solaris 10

Dear Solaris Experts, I would like to set the lowest priority when running a resource intensive program in C shell on Solaris 10 similar to the following syntax that works in Korn shell: $ nice -n 19 programHowever, I got the following error when running the same command in C shell: 9 ... (3 Replies)
Discussion started by: gjackson123
3 Replies

4. Shell Programming and Scripting

syntax error near unexpected token `for file in

I am trying to run the code below however I am getting a "syntax error near unexpected token `for file in error" on the line that is in red. I have the semicolons after every line because it will fail on the copy if I don't have them saying that it cannot stat directory. Is there something that I... (3 Replies)
Discussion started by: coach5779
3 Replies

5. Shell Programming and Scripting

syntax error: unexpected end of file

Hi, I am newbie to UNIX scripting. I am facing this error "syntax error: unexpected end of file" while executing the following script: ------ a=$1 if then sqlplus -s prospect_stg/prospect_stg@mdmpt <<END insert into bckup_marc_parameter_lookup select * from... (6 Replies)
Discussion started by: boopathyvasagam
6 Replies

6. Shell Programming and Scripting

syntax error: unexpected end of file

I have a script that's failing ./zzmaster.sh: line 2: syntax error: unexpected end of file There are 4 scripts total involved. The first 'znocc0.sh' essentially curls a page then does some sed sequences... #!/bin/sh #GET SENTINAL INFO curl -b z0cookie.txt -L -k -e... (2 Replies)
Discussion started by: phpfreak
2 Replies

7. Shell Programming and Scripting

syntax error: unexpected end of file

Hi, I need ur help is this matter, i have th ebelow script, and i keep getting this error: syntax error: unexpected end of file affectedRow=`cat dbOutput.log | grep "1 row affected"` echo "affectedRow : $affectedRow" if ; then echo "Look to the next OMCDB" ... (10 Replies)
Discussion started by: Alaeddin
10 Replies

8. UNIX for Dummies Questions & Answers

Syntax Error Suders file

Hi, I tried to edit my sudoers file using visudo and placed some valid entries. when i tried to save the file. the system warned me that the file holds error at line 26 and asked me what to do. I just quited the task and file was not saved. I wonder what might be the error , for review... (0 Replies)
Discussion started by: Asteroid
0 Replies

9. UNIX for Dummies Questions & Answers

csh syntax

I am trying to list output in columns in csh. What would be the syntax for this shell if in ksh it is: ls -d !(*SNMP*) ? (0 Replies)
Discussion started by: charlie11k
0 Replies

10. Shell Programming and Scripting

if-else syntax in csh

Dear friends, I am writing a script usiing c-shell. iwant if -else syntax in c-shell i have taken twovariables and in one variable iam storing sysdate.and comparing with other variable if both are same then iam renaming file as oct_2005. please see below code set mon=`date +%m`... (1 Reply)
Discussion started by: rajan_ka1
1 Replies
Login or Register to Ask a Question