when I was trying to install a software "AutoMar", as it was written in the readme, I runned the script: sh automar-install, but it failed:
automar-install: line 17: syntax error near unexpected token `('
automar-install: line 17: `set OS = ( 'uname' )'
My OS: RedHat FC3 2.6.11.11 bash(I tried csh, but it didn't work)
the code of "automar-install"
#!/bin/csh -f
#
#############################
# Echo input and output files
#############################
#
echo ""
echo " ***************************************"
echo " * *"
echo " * automar Software Installation Script *"
echo " * *"
echo " ***************************************"
echo ""
set ARG0 = $0
set OS = ( 'uname' )
set F = ( '$HOME/.cshrc' )
set version = 0
set done = 0
set more = 0
#################
# Check for flags
#################
while ( $done == 0 )
switch ($1 )
case '-v':
case '-V':
@ more++
set argv = ( $argv[2-] )
breaksw
case '-os':
case '-OS':
set OS = $2
set argv = ( $argv[3-] )
breaksw
case '-h':
case '-H':
case '--help':
case '-help':
goto USAGE
breaksw
case '-d':
case '-D':
default:
set INSTDIR = $1
set done = 1
endsw
end
# Set up default directory, depending on OPERATING system
set DEFDIR = ( ${HOME}/automar )
#
# Choose OS
#
if ( $OS == 'OSF1' ) then
set A = ( 'osf' )
else if ( $OS == 'IRIX' ) then
set A = ( 'sgi' )
else if ( $OS == 'Linux' ) then
set A = ( 'linux' )
else if ( $OS == 'Darwin' ) then
set A = ( 'ppc' )
endif
if ( ${INSTDIR} != '' ) goto CHECK_DIR
#
# Set up default directory, depending on OS
#
NEWDIR:
echo ""
echo "Enter target directory (or 'q' or Ctrl/C to interrupt) [ $DEFDIR ]: "
set INSTDIR = ( $< )
if ( ${INSTDIR} == '' ) then
set INSTDIR = $DEFDIR
else if ( ${INSTDIR} == 'q' || ${INSTDIR} == 'Q' ) then
echo "SETUP: Abandoning installation..."
exit
endif
echo ""
#
# Does directory exist ?
#
CHECK_DIR:
while ( ! -d ${INSTDIR} )
if ( -f ${INSTDIR} ) then
echo "SETUP: ${INSTDIR} is not a directory! Choose another one ..."
set DEFDIR = ${INSTDIR}
goto NEWDIR
else
echo -n "SETUP: ${INSTDIR} does not exist! Create it (y/n) [Y]: "
set ans = ( $< )
if ( $ans == 'n' || $ans == 'N' ) then
set DEFDIR = ${INSTDIR}
goto NEWDIR
else
mkdir ${INSTDIR} >& /dev/null
if ( ! -d ${INSTDIR} ) then
echo "SETUP: You don't have permission to create ${INSTDIR} ."
set DEFDIR = ${INSTDIR}
goto NEWDIR
endif
endif
endif
end
#
# Do we have write permission to {INSTDIR}?
#
if ( ! -w ${INSTDIR} ) then
echo "SETUP: You don't have write access to ${INSTDIR} ! "
set DEFDIR = ${INSTDIR}
goto NEWDIR
endif
#
# Get the directory name part of setup
#
set SRCDIR = ( `echo "$ARG0" | awk '{split( $1, a, "automar-install" );
print a[1]}' ` )
if ( ${SRCDIR} == '' ) then
set SRCDIR = ( . )
endif
if ( ! -d ${SRCDIR} ) then
echo "SETUP: cannot change directory to ${SRCDIR} . Something really wrong"
exit
endif
#
#
# So target directory is okay. Now test capacity
# CAP1: disk space of distribution (used)
# CAP2: disk space in target directory (available)
#
set CAP1 = ( `du -k -s ${SRCDIR} | awk '{print $1}' `)
if ( $OS == 'IRIX' ) then
set CAP2 = ( `df -k ${INSTDIR} |grep "/"| awk '{print $5}' `)
else
set CAP2 = ( `df -k ${INSTDIR} |grep "/"| awk '{print $4}' `)
endif
set MB = ( kB )
if ( $CAP1 > 10240 || $CAP2 > 10240 ) then
@ CAP1 /= 1024
@ CAP2 /= 1024
set MB = ( MB )
endif
if ( $CAP2 < $CAP1 ) then
echo "SETUP: Available disk space in [${INSTDIR}]: $CAP2 $MB "
echo " The automar distribution needs: $CAP1 $MB "
echo " You must select another directory or create more space"
set DEFDIR = ${INSTDIR}
goto NEWDIR
endif
#
# Is target directory empty?
#
set LSDIR= ( `/bin/ls -la ${INSTDIR}| wc -l` )
if ( $LSDIR > 3 ) then
echo "SETUP: Target directory ${INSTDIR} is not empty! "
echo "SETUP: Do you want to list contents (l/L), quit (q/Q),"
echo " erase (e/E) or overwrite (o/O) [o]?"
set ans = ( $< )
if ( $ans == 'q' || $ans == 'Q' ) then
exit
else if ( $ans == 'l' || $ans == 'L' ) then
echo "====================================================="
echo "Contens of ${INSTDIR} :"
echo "====================================================="
/bin/ls -Rla ${INSTDIR}
echo "====================================================="
echo ""
echo "SETUP: Quit (q/Q), erase (e/E) or overwrite (o/O) [o]?"
set ans = ( $< )
if ( $ans == 'q' || $ans == 'Q' ) then
exit
endif
endif
#
# We want to clean directories first
#
if ( $ans == 'e' || $ans == 'E' ) then
echo "SETUP: Entire directory tree ${INSTDIR} will be deleted! "
echo " Continue (c/C) or quit (q/Q) [q] ?"
set ans = ( $< )
if ( $ans == 'c' || $ans == 'C' ) goto CONTINUE1
exit
CONTINUE1:
# Delete tree
echo "SETUP: Removing ${INSTDIR} ... "
/bin/rm -r ${INSTDIR}
# Create it again:
mkdir ${INSTDIR}
endif
endif
#
# Here we go. Copy directory tree
#
cd ${SRCDIR}
echo "=================================================================="
echo "SETUP: Now copying files from ${SRCDIR} to ${INSTDIR} ..."
echo "=================================================================="
#
if ( -f ${SRCDIR}/automar.tar ) then
echo "SETUP: Unpacking ${SRCDIR}/automar.tar ... "
cd ${INSTDIR}
tar xvfR ${SRCDIR}/automar.tar
else
tar cf - . | ( cd ${INSTDIR}; tar xvf - )
endif
#
# Change read/write permissions
#
cd ${INSTDIR}
chmod -R a+r .
chmod -R +w .
if ( -f automar-install ) then
/bin/rm automar-install
endif
if ( -f setup_gui ) then
/bin/rm setup_gui
endif
if ( -f automar.tar ) then
/bin/rm automar.tar
endif
#
#*****************************************************************************
# Copy done, check environs and modify .cshrc
#*****************************************************************************
#
echo ""
echo "======================================================================="
echo "SETUP: Files have been copied successfully. "
echo "======================================================================="
echo "SETUP: To use the automar suite, some environment variables must be set."
echo "SETUP: Should 'SETUP' modify your shell-login script (y/n) [n] ?"
set ans = ( $< )
if ( $ans == 'y' || $ans == 'Y' ) then
if ( ! $?SHELL ) then
echo "SETUP: Default shell not defined. Must finish now ..."
goto ALL_DONE
endif
if ( ${SHELL} == '/bin/tcsh' && -f ${HOME}/.tcshrc ) then
set FILE = ( $HOME/.tcshrc )
else if ( ${SHELL} == '/bin/tcsh' && -f ${HOME}/.cshrc ) then
set FILE = ( $HOME/.cshrc )
else if ( ${SHELL} == '/bin/csh' && -f ${HOME}/.cshrc ) then
set FILE = ( $HOME/.cshrc )
else if ( ${SHELL} == '/bin/bash' && -f ${HOME}/.bashrc ) then
set FILE = ( $HOME/.bashrc )
else
set FILE = ( 'UNKNOWN' )
echo "SETUP: Your login shell must be either csh or tcsh".
echo " Must finish now ...".
goto ALL_DONE
endif
else
goto ALL_DONE
endif
# Try to see if AUTOMARDIR has been defined
set Q = ( `cat ${FILE} | grep AUTOMARDIR | awk '{printf "%s", $3}' ` )
# This seeems to be a first time installation
if ( ${Q} == '' ) then
set Q = ( ${HOME}/automar )
echo "SETUP: This is a first time installation"
else
echo "SETUP: AUTOMARDIR is already defined as: $Q "
goto ALL_DONE
endif
#
# Make a backup copy of the login script
#
set N = 1
while ( -f $FILE.bck.$N )
@ N++
end
echo "SETUP: Saving $FILE into $FILE.bck.$N ... "
set F = ${FILE}
cd $HOME
/bin/cp $F ${FILE}.bck.$N
set S = ( '$PATH' )
set M = ( '${MANPATH}' )
set N = ( '$?MANPATH' )
set C = ( '$?CCP4' )
set CC= ( '$CCP4' )
echo "#" >> $F
echo "#################################################################" >> $F
echo "# `date`: " >> $F
echo "# Defining environment for automar suite " >> $F
echo "#################################################################" >> $F
echo "#" >> $F
#
# Bash and csh have different syntax. Stuff for bash first ...
#
if ( ${SHELL} == '/bin/bash' ) then
echo "if [ -d ${INSTDIR}/bin/${A} ]; then" >> $F
echo " export PATH=${S}:${INSTDIR}/bin/${A} " >> $F
echo " if [ ${N} ]; then " >> $F
echo " MANPATH=${M}:${INSTDIR}/man " >> $F
echo " else " >> $F
echo " MANPATH=${INSTDIR}/man " >> $F
echo " fi " >> $F
echo " export AUTOMARDIR=${INSTDIR} " >> $F
echo " if test -z ${CC}; then" >> $F
echo " test -s ${INSTDIR}/ccp4/ccp4.sh && . ${INSTDIR}/ccp4/ccp4.sh " >> $F
echo " fi" >> $F
echo "fi" >> $F
#
# Stuff for csh and similars
#
else
echo "if ( -d ${INSTDIR}/bin/${A} ) then" >> $F
echo " set path = ( $S ${INSTDIR}/bin/${A} ) " >> $F
echo " if ( ${N} ) then " >> $F
echo " setenv MANPATH ${M}:${INSTDIR}/man " >> $F
echo " else " >> $F
echo " setenv MANPATH ${INSTDIR}/man " >> $F
echo " endif " >> $F
echo " setenv AUTOMARDIR $Q " >> $F
echo " if ( ! $C && -f ${INSTDIR}/ccp4/ccp4.csh ) then" >> $F
echo " source ${INSTDIR}/ccp4/ccp4.csh" >> $F
echo " endif" >> $F
echo "endif" >> $F
endif
#
#*****************************************************************************
# All done:
#*****************************************************************************
#
#
ALL_DONE:
echo ""
echo "======================================================================="
echo "SETUP: All done ! "
echo " Source $F and type 'automar' ..."
echo "======================================================================="
exit
#
#*****************************************************************************
# usage ...
#*****************************************************************************
#
USAGE:
echo ""
echo " ==============================================================="
echo ""
echo " Usage instructions:"
echo " ==================="
echo ""
echo " setup [target_directory]"
echo ""
echo " E.g.: setup ${HOME}/automar"
echo ""
echo " If 'target_directory' is omitted, the program will prompt for it."
echo " When hitting return at the prompt, the default in [] will be used"
echo " unless other input is given"
echo ""
echo " setup will copy the directory tree to [target_directory]."
echo " The program also checks access permissions and disk space."
echo ""
echo " ==============================================================="
echo ""
exit