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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ENVIRON doesn't work 1

Status
Not open for further replies.

chirpyform

Programmer
Jun 20, 2003
202
FR
I have the following code in a script ksh:
step1()
{

#//*- CREATION DES FICHIERS POUR DIFFERENTES LOCALITES ------------------
#//*---------------------------------------------------------------------
#//*---------------------------------------------------------------------

export FENTREE1=${RADIC}/adr1.tri
export FSORTIE1=/data/PROJETS/DRACCO/wdir/aud/localite
export FEXTRACT=$Shell.step1.awk

cat > ${FEXTRACT} <<-""EOF
BEGIN {FS=";"
OFS=";"
cle_prec = ""
cle = ""
file_int = 0
file_name = ""
FSortie1=ENVIRON["FSORTIE1"]
}
{
cle = $13
if ( cle_prec != cle )
{
file_int = file_int + 1
}

file_name = FSortie1 file_int
print file_name
print $0 > file_name
cle_prec = cle
}
EOF


echo "CREATION DES FICHIERS POUR DIFFERENTES LOCALITES"
echo "FENTREE1 :" ${FENTREE1}
echo "FSORTIE1 :" ${FSORTIE1}


LC_NUMERIC=fr_FR.ISO8859-1 awk -f ${PARAM}/${FEXTRACT} ${FENTREE1} > ${FSORTIE1}

if [ $? -ne 0 ]
then
echo "Probleme dans le awk"
exit 1
fi
export FENTREE1=
export FSORTIE1=

}

the problem is that FSortie1 is empty. I have used almost exactly the same code in another environment and it worked. Is this a problem to do with my version of AWK.
I am working with :
Machine hardware: sun4u
OS version: 5.9
Processor type: sparc
Hardware: SUNW,Sun-Fire-V440

The following components are installed on your system:


Forte C 6 update 2
Sun WorkShop 6 update 2 Compilers C
Sun WorkShop 6 update 2 Development Environment
Sun WorkShop 6 update 2 DBX Debugging Tools
Sun WorkShop 6 update 2 Building Software
Sun WorkShop 6 update 2 Performance Analyzer
XEmacs 20.4 Source Distribution
Sun WorkShop 6 update 2 Documentation Set

Sun WorkShop 6 update 2 FileMerge

any help would be appreciated

Chris
 
Have you tried nawk ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
what do i need to do to have the version nawk ?

Chris
 
tried with /usr/xpg4/bin/awk already?

. Mac for productivity
.. Linux for developement
... Windows for solitaire
 
In the end I used

/usr/xpg4/bin/awk -v FSortie1=$FSORTIE1 'awk code'

thanks everyone

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top