[clug] can't invoke ex from inside an if statement

Kim Holburn kim.holburn at anu.edu.au
Mon Nov 24 15:17:12 EST 2003


At 2:57 PM +1100 2003/11/24, Rousak, Boris wrote:
>Greetings all,
>I am stumped on this seemingly obvious problem so any hints/advice would be
>very much appreciated. I wrote the following script using ex:
>
>#!/bin/ksh
>ex - myfile << EOF
>/15:01:06/ | .= | d | a |Nov 14 15:01:06 /usr: 1
>.
>.
>wq

Well you've forgotten the end of the inline redirector:

#!/bin/ksh
ex - myfile << EOF
/15:01:06/ | .= | d | a |Nov 14 15:01:06 /usr: 1
.
.
wq
EOF


>And it works fine, when run from the command line like so ./myscript
>But when I add a simple if statement to the script:
>
>#!/bin/ksh
>if [[ 1 = 1 ]]; then
>{
>ex - myfile << EOF
>/15:01:06/ | .= | d | a |Nov 14 15:01:06 /u20: 1
>.
>.
>wq
>}
>fi

#!/bin/ksh
if [[ 1 = 1 ]]; then
{
ex - myfile << EOF
/15:01:06/ | .= | d | a |Nov 14 15:01:06 /u20: 1
.
.
wq
EOF
}
fi


>and run again I get the following error message:
>./myscript[2]: syntax error at line 4 : `
>where line 4 is the line invoking ex i.e. ex - myfile << EOF.
>I've tested the if statement on its own and it works fine, so does anyone
>have any ideas on what am I doing wrong here?
>
>Cheers,
>Boris
>
>
>************************************************************************
>*PLEASE NOTE*  This email and any attachments may
>be confidential. If received in error, please delete all
>copies and advise the sender. The reproduction or
>dissemination of this email or its attachments is
>prohibited without the consent of the sender.
>
>WARNING RE VIRUSES:  Our computer systems sweep
>outgoing email to guard against viruses, but no warranty
>is given that this email or its attachments are virus free.
>Before opening or using attachments, please check for
>viruses.  Our liability is limited to the re-supply of any
>affected attachments.
>
>Any views expressed in this message are those of the
>individual sender, except where the sender expressly,
>and with authority, states them to be the views of the
>organisation.
>************************************************************************


-- 
--
Kim Holburn 
Network Consultant - Telecommunications Engineering
Research School of Information Sciences and Engineering
Australian National University - Ph: +61 2 61258620 M: +61 0417820641
Email: kim.holburn at anu.edu.au  - PGP Public Key on request

Life is complex - It has real and imaginary parts.
     Andrea Leistra (rec.arts.sf.written.Robert-jordan)



More information about the linux mailing list