Hello,
I tried to come up a shell script to simplify the compiling command, but I don’t know why it does not work.
The original command is
cc -DHDFSYS –o ReadGDflds.o -I$HDFINC -I$HDFEOS_INC –c ReadGDflds.c
cc -DHDFSYS –o ReadGDflds ReadGDflds.o -L$HDFLIB -L$HDFEOS_LIB -lhdfeos -1Gctp -lmfhdf -ldf -ljpeg -lnsl -lz –lm
These commands work fine in command line, but it is too long for typing each time. So, I wrote a short sh script as below
##############################################################
#! /bin/sh -f
set LDFLAGS = '-lhdfeos -1Gctp -lmfhdf -ldf -ljpeg -lnsl -lz -lm'
set INCLUDE = '-I$HDFINC -I$HDFEOS_INC'
set LIBRARY = '-L$HDFLIB -L$HDFEOS_LIB'
foreach name ($argv)
if ( -f $name ) then
echo -n "compile and link '${name}'.c"
cc -DHDFSYS -o ${name}.o ${INCLUDE} -c ${name}.c
cc -DHDFSYS -o ${name} ${name}.o ${LIBRARY} ${LDFLAGS}
else
echo -n " file '${name}'.c is not found"
endif
end
#######################
I named it as fhdf.sh, and chmod u+x fhdf.sh. But while I ran with input as ReadGDflds, it gives a wrong message
f90HDF> fhdf ReadGDflds
fhdf.sh ReadGDflds
fhdf.sh: syntax error at line 6: `(' unexpected
Would anyone please help to check out what is wrong with this short script?
Thanks a lot
I tried to come up a shell script to simplify the compiling command, but I don’t know why it does not work.
The original command is
cc -DHDFSYS –o ReadGDflds.o -I$HDFINC -I$HDFEOS_INC –c ReadGDflds.c
cc -DHDFSYS –o ReadGDflds ReadGDflds.o -L$HDFLIB -L$HDFEOS_LIB -lhdfeos -1Gctp -lmfhdf -ldf -ljpeg -lnsl -lz –lm
These commands work fine in command line, but it is too long for typing each time. So, I wrote a short sh script as below
##############################################################
#! /bin/sh -f
set LDFLAGS = '-lhdfeos -1Gctp -lmfhdf -ldf -ljpeg -lnsl -lz -lm'
set INCLUDE = '-I$HDFINC -I$HDFEOS_INC'
set LIBRARY = '-L$HDFLIB -L$HDFEOS_LIB'
foreach name ($argv)
if ( -f $name ) then
echo -n "compile and link '${name}'.c"
cc -DHDFSYS -o ${name}.o ${INCLUDE} -c ${name}.c
cc -DHDFSYS -o ${name} ${name}.o ${LIBRARY} ${LDFLAGS}
else
echo -n " file '${name}'.c is not found"
endif
end
#######################
I named it as fhdf.sh, and chmod u+x fhdf.sh. But while I ran with input as ReadGDflds, it gives a wrong message
f90HDF> fhdf ReadGDflds
fhdf.sh ReadGDflds
fhdf.sh: syntax error at line 6: `(' unexpected
Would anyone please help to check out what is wrong with this short script?
Thanks a lot