Confusion about IFS Variable

=================================================
#!/bin/sh
HOST=eux091
if [ -s /etc/maestab ] && grep -q $HOST /etc/maestab
then
IFS=:
grep -v -e "^#" -e "^$" /etc/maestab | grep $HOST | \
read HOST MAESTRO_BIN FLAG MAESTRO_USER
echo $MAESTRO_BIN
MAESTRO_HOME=`dirname $MAESTRO_BIN`
echo $MAESTRO_HOME
fi

here is /etc/maestab

eul3p3:/opt/maes3p3/maestro/bin:Y:maes3p3

==================================================
script working fine with HP-UX but not in Linux, can you help me out where I am wrong.

Dirname is part of coreutils Linux package.
Do you have the coreutils installed on your Linux system?

Regards

Works for me using ksh on linux - provided you set HOST to a value that is in maestab

Frank,

dirname works wihout issue.

fpm,

oops!! sorry, i have copied script from my hp-ux system and maestab from linux system. but actully I am paasing value of $HOST by $1 in my script.
pls read HOST=eul3p3 in this case.

Thanks.

Awadhesh

A script like:
#! /bin/sh
echo hello | read word ; echo word = $word
will work on HP-UX but fail on Linux. HP's /bin/sh is a modified version of the real Korn shell. But Linux's /bin/sh is a linked version of bash. The real Korn shell is the only shell that executes the last command of a pipeline in the context of the current shell provided that the last command is a shell built-in. Other shells will fork a new process to handle that "read word". The subprocess will exit and back in the parent, the variable "word" never got a new value. Beware: Linux often has pd-ksh which will behave the same way.

thanks, u always come with a torch.

pd-ksh is there, but i really dont know how to use it in script.

[root@eul3p3 tmp]# rpm -qa|grep -i pdksh
pdksh-5.2.14-30.3
[root@eul3p3 tmp]#

Awadhesh

Well, considering that pd-ksh will fail in the same manner that bash does, I'm not sure that this is any great loss. But just use
#! /usr/bin/ksh
on Linux to invoke pd-ksh. I believe that the real ksh is available for Linux, but I don't know how you get it. You need to stop doing
some-command | read this that
to get your script to work with bash or pd-ksh. If you can't think of anything else,
some-command > tempfile
read this that < tempfile
rm tempfile
should do it.

Well, I thought and implemented that way only, but feel that its a rough idea.
Thanks again for your great help. Awadhesh