Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with cshell script to read 1 or more lex files

Status
Not open for further replies.

davemib

Programmer
Dec 31, 2002
30
0
0
GB
takes one or more .l files and compiles them

#!/usr/bin/csh
#while loop to carry on asking user to enter the files
while $number!=0
echo "enter file name"

#check to see if file ends with .l

#if file ends with .l compile lexx.yy.c file for each file

this is how i think it needs to be done but im not sure?????

can ne1 help me

this is what i've come up with am gettign errors

#!/bin/csh
while read -a lfiles -p "Enter files to process:"; do
for file in "${lfiles[@]}";do
if[ "${file##*.}" == "l" ];then
# Place your compilation procedure
cc -o "${file##*.}" lex.yy.c -ll
fi
done
done
 


Why are using CSH? this looks like a perfectly valid

SH/KSH/BASH script to me.

Change the top line to

from

#! /bin/csh

to

#! /bin/sh


And it will work fine.

---
 
Shouldn't you be using [tt]make[/tt] for compiling programs?

Make knows about dependency rules, so it can minimise the amount of work which needs to be done, which can be considerable on a large project.

--
 
i am having a few problems witht his script on these lines :

if[ "${file##*.}" == "l" ];then
# Place your compilation procedure
cc -o "${file##*.}" lex.yy.c -ll
fi

just won't compile
 
if[ "${file##*.}" == "l" ];then
Lack of spaces delimiters, try something like this:
if [ "${file##*.}" == "l" ]; then
Anyway, post the error message instead of only "won't compile"

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top