Unix administration - hpux 11 here document problem

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > November 2005 > hpux 11 here document problem





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author hpux 11 here document problem
KT

2005-11-09, 5:53 pm

Hi All,

The OS is "HP-UX tuna B.11.00 U 9000/800 522706547 unlimited-user
license"
When the following function is called, it always complain
"ksh: syntax error at line 6 : `fi' unexpected"

I put in print statements for debugging and found that this error is
generated at "EMB_BUILD" delimiter-word of the here document at the end
of the function.

Is this a bug in the shell? How do I get around of it?

function emb_build {
ALL=FALSE
LASB=FALSE
IAHV=FALSE
ISH=FALSE
RSH=FALSE

PS3='Pick one of the above:'
select i in all lasb iahv ish rsh finish
do case $i in
all) ALL=TRUE
break;;
iahv) IAHV=TRUE;;
lasb) LASB=TRUE;;
ish) ISH=TRUE;;
rsh) RSH=TRUE;;
finish) print -u2 "finished embedded selection"
break;;
esac
done

if [ $ALL = TRUE ]
then
IAHV=TRUE
LASB=TRUE
ISH=TRUE
RSH=TRUE
fi

$CL setview P10_V230_EMB_Build << EMB_BUILD

if [ $DEL_FLAG = TRUE ]
delay # sleep and wake up sometime after midnight
DEL_FLAG=FALSE # Only 1 delay allowed
fi

if [ $IAHV = TRUE ] # iahv build
then
test -f $curDir/Embd_builds/iahv/ArchitectProjects/done.txt && rm -f
$curDir/E
mbd_builds/iahv/ArchitectProjects/done.txt
cd $curDir/Embd_builds/iahv
../bigbang.sh -e IAHV.prj
fi

if [ $LASB = TRUE ] # lasb build
then
test -f $curDir/Embd_builds/lasb/ArchitectProjects/done.txt && rm -f
$curDir/
Embd_builds/lasb/ArchitectProjects/done.txt
cd $curDir/Embd_builds/lasb
../bigbang.sh -e P6_LSH.prj
fi

if [ $ISH = TRUE ] # ish build
then
test -f $curDir/Embd_builds/ish/ArchitectProjects/done.txt && rm -f
$curDir/Em
bd_builds/ish/ArchitectProjects/done.txt
cd $curDir/Embd_builds/ish
../bigbang.sh -e ISH.prj
fi

if [ $RSH = TRUE ] # rsh build
then
test -f $curDir/Embd_builds/rsh/ArchitectProjects/done.txt && rm -f
$curDir/Em
bd_builds/rsh/ArchitectProjects/done.txt
cd $curDir/Embd_builds/rsh
../bigbang.sh -e RSH.prj
fi

EMB_BUILD
}


========================================
=========================
Snippet of the output:

+ [ TRUE = TRUE ]
+ emb_build
1) all
2) lasb
3) iahv
4) ish
5) rsh
6) finish
Pick one of the above:4
Pick one of the above:6
finished embedded selection
ksh: syntax error at line 6 : `fi' unexpected
+ [ FALSE = TRUE ]
+ [ FALSE != TRUE ]
+ scc_build

Fletcher Glenn

2005-11-09, 5:53 pm

KT wrote:
> Hi All,

<snipped>
> if [ $ALL = TRUE ]
> then
> IAHV=TRUE
> LASB=TRUE
> ISH=TRUE
> RSH=TRUE
> fi

<snipped>

The correct format for the above is:

if [ $ALL = TRUE ] ; then
....
....
fi

Note the semicolon above.

--

Fletcher Glenn

Ed Morton

2005-11-09, 5:53 pm



Fletcher Glenn wrote:
> KT wrote:
>
>
> <snipped>
>
>
> <snipped>
>
> The correct format for the above is:
>
> if [ $ALL = TRUE ] ; then
> ...
> ...
> fi
>
> Note the semicolon above.


No, the original is fine. Whether you do this:

if [ whatever ] ; then

or this:

if [ whatever ]
then

is purely a matter of taste/style.

Ed.
Ralf Fassel

2005-11-09, 5:53 pm

* "KT" <kerr_tung@yahoo.com>
| if [ $IAHV = TRUE ] # iahv build

Have you tried w/o the comment after the test?

# iahv build
if [ $IAHV = TRUE ]
then
...

HP once didn't like comments or flags in the #!/bin/sh line either...

R'
S. Anthony Sequeira

2005-11-09, 5:53 pm

KT wrote:

> $CL setview P10_V230_EMB_Build << EMB_BUILD
>
> if [ $DEL_FLAG = TRUE ]
> delay # sleep and wake up sometime after midnight
> DEL_FLAG=FALSE # Only 1 delay allowed
> fi


There *is* a 'then' missing.
--
Tony
Sven Mascheck

2005-11-09, 5:53 pm

[f'up2 c.u.shell]

Ralf Fassel wrote:
> | if [ $IAHV = TRUE ] # iahv build
>
> Have you tried w/o the comment after the test?


To the best of my knowledge, all bourne compatible shells properly
parse such a line (given correct syntax in the following lines).

> HP once didn't like comments or flags in the #!/bin/sh line either...


That's a completely different issue because the #! line is parsed
by the kernel and not by a shell. On most unix variants, including
HP-UX 8-11, the whole line is passed on as one argument. Important
exceptions are SunOS 5, OpenServer 5 and Ultrix, which split and
pass on the first "argument" only, and FreeBSD which really splits
up and fills argv[].
Jan Gerrit Kootstra

2005-11-10, 2:49 am

Ralf Fassel wrote:
> * "KT" <kerr_tung@yahoo.com>
> | if [ $IAHV = TRUE ] # iahv build
>
> Have you tried w/o the comment after the test?
>
> # iahv build
> if [ $IAHV = TRUE ]
> then
> ...
>
> HP once didn't like comments or flags in the #!/bin/sh line either...
>
> R'

Ralf,


I was more think of:

if [ $IAHV ="TRUE" ]
then
.....


Regards,


Jan Gerrit
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com