I don t understand the eand if file unexepected expecting done, done is ?

I don t understand the eand if file unexepected expecting done, done is ?

Post by David » Thu, 10 Jan 2002 07:53:05



for REP in `find -type d -name include` ; do

sed "s/easyphp/easyphp14/g" < $REP/common.inc.php > $REP/commonlucas.inc.php

sed "s/\/tata\//\/tata-conseil\//g" < $REP/commonlucas.inc.php >
$REP/common.inc.php

rm -f $REP/commonlucas.inc.php

done

thanks.

 
 
 

I don t understand the eand if file unexepected expecting done, done is ?

Post by Bill Marcu » Thu, 10 Jan 2002 18:05:01



>for REP in `find -type d -name include` ; do

>sed "s/easyphp/easyphp14/g" < $REP/common.inc.php >

$REP/commonlucas.inc.php
Quote:

>sed "s/\/tata\//\/tata-conseil\//g" < $REP/commonlucas.inc.php >
>$REP/common.inc.php

>rm -f $REP/commonlucas.inc.php

>done

The "end of file unexpected" error is usually caused by a missing quote,
parenthesis, or other punctuation.  Is your post an exact copy of the script
(pasted, not retyped)?  To find the error, you might temporarily move the
"done".

 
 
 

I don t understand the eand if file unexepected expecting done, done is ?

Post by David » Thu, 10 Jan 2002 21:34:52


I have no longer problem with the script
for REP in `find -type d -name include` ; do
sed "s/easyphp/easyphp14/g" < $REP/common.inc.php > $REP/commonlucas.inc.php

sed "s/\/tata\//\/tata-conseil\//g" < $REP/commonlucas.inc.php >
$REP/common.inc.php

rm -f $REP/commonlucas.inc.php

done

when I put it into a .sh file and execute it.

But when trying to make a makefile see it with target lucas, it doesn t work
:

lucas:

    for REP in `find -type d -name include` ; do

    sed "s/easyphp/easyphp14/g" < $REP/common.inc.php >
$REP/commonlucas.inc.php

    sed "s/\/tata\//\/tata-conseil\//g" < $REP/commonlucas.inc.php >
$REP/common.inc.php

    rm -f $REP/commonlucas.inc.php

    done

I make :

$>make lucas

In this cas I have a syntax error : end of file unexpected (expecting done)

make : *** [lucas] Error 2

my make in, under cygwin under windows.

thanks.

 
 
 

I don t understand the eand if file unexepected expecting done, done is ?

Post by Barry Margoli » Fri, 11 Jan 2002 04:48:07



>But when trying to make a makefile see it with target lucas, it doesn t work
>:

Make expects the entire shell command to be on a single line of the file.
If you need to spread it over multiple lines, you must escape the newline
with '\':

lucas:
   for REP in `find -type d -name include`; do \
   sed "s/easyphp/easyphp14/g" < $$REP/common.inc.php > $$REP/commonlucas.inc.php \
   sed "s/\/tata\//\/tata-conseil\//g" < $$REP/commonlucas.inc.php > $$REP/common.inc.php \
   rm -f $$REP/commonlucas.inc.php \
   done

Also, notice that you have to use $$REP instead of $REP, because $REP would
try to access a make variable instead of the shell variable.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

I don t understand the eand if file unexepected expecting done, done is ?

Post by David » Fri, 11 Jan 2002 04:58:35


thanks a lot.
 
 
 

I don t understand the eand if file unexepected expecting done, done is ?

Post by Heiner Marx » Fri, 11 Jan 2002 03:40:11



>I have no longer problem with the script
>for REP in `find -type d -name include` ; do
>sed "s/easyphp/easyphp14/g" < $REP/common.inc.php > $REP/commonlucas.inc.php

>sed "s/\/tata\//\/tata-conseil\//g" < $REP/commonlucas.inc.php >
>$REP/common.inc.php

>rm -f $REP/commonlucas.inc.php

>done

>when I put it into a .sh file and execute it.

>But when trying to make a makefile see it with target lucas, it doesn t work
>:

>lucas:

>    for REP in `find -type d -name include` ; do

>    sed "s/easyphp/easyphp14/g" < $REP/common.inc.php >
>$REP/commonlucas.inc.php

>    sed "s/\/tata\//\/tata-conseil\//g" < $REP/commonlucas.inc.php >
>$REP/common.inc.php

>    rm -f $REP/commonlucas.inc.php

>    done

>I make :

>$>make lucas

>In this cas I have a syntax error : end of file unexpected (expecting done)

>make : *** [lucas] Error 2

>my make in, under cygwin under windows.

"make" excutes the actions (indented lines) one line at a time, calling
    $(SHELL) -ce "action line"
for each of it.

So, you have to make a one-liner of the for...do..done, by escaping the
newlines with backslashes (causing make to omit the backslash/newline),
and inserting appropriate ";" to tell the shell where to separate commands.
Also, in order to use shell variables you have to double the "$"s,
to cause "make" to not interpret it, but pass a single "$" to the shell.
Otherwise $REP would be replaced by the contents of the make variable R
followed by EP.  Try:

lucas:
        for REP in `find -type d -name include` ; do            \
        sed "s/easyphp/easyphp14/g" < $$REP/common.inc.php \
                > $$REP/commonlucas.inc.php ;                        \
        sed "s/\/tata\//\/tata-conseil\//g" < $$REP/commonlucas.inc.php    \
                > $$REP/common.inc.php ;                     \
        rm -f $$REP/commonlucas.inc.php ;                       \
        done

Is a bit ugly, yes.

Alternatively, put the code into a shell script, and simply call that.
--

 
 
 

I don t understand the eand if file unexepected expecting done, done is ?

Post by Tinti » Fri, 11 Jan 2002 06:30:34



Quote:> I have no longer problem with the script
> for REP in `find -type d -name include` ; do
> sed "s/easyphp/easyphp14/g" < $REP/common.inc.php >

$REP/commonlucas.inc.php

Quote:

> sed "s/\/tata\//\/tata-conseil\//g" < $REP/commonlucas.inc.php >
> $REP/common.inc.php

> rm -f $REP/commonlucas.inc.php

> done

> when I put it into a .sh file and execute it.

> But when trying to make a makefile see it with target lucas, it doesn t
work
> :

> lucas:

>     for REP in `find -type d -name include` ; do

>     sed "s/easyphp/easyphp14/g" < $REP/common.inc.php >
> $REP/commonlucas.inc.php

>     sed "s/\/tata\//\/tata-conseil\//g" < $REP/commonlucas.inc.php >
> $REP/common.inc.php

>     rm -f $REP/commonlucas.inc.php

>     done

> I make :

> $>make lucas

> In this cas I have a syntax error : end of file unexpected (expecting
done)

> make : *** [lucas] Error 2

> my make in, under cygwin under windows.

That was a *very* important piece of information you didn't mention in the
OP
 
 
 

I don t understand the eand if file unexepected expecting done, done is ?

Post by David » Fri, 11 Jan 2002 06:32:59


I think it has no interest, but in fact.