0

I am trying to modify the .tcshrc file in OSX to include shell environment variables for installing GNURadio. However, it returns me an error message like this

"-bash: /Users/admin/.tcshrc: line 22: syntax error: unexpected end of file"

The modified tcshrc file is as follows

 if (-r /opt/local/bin/port) then
      setenv LDFLAGS "-L/opt/local/lib ${LDFLAGS}"
      setenv PATH ${HOME}/bin:/opt/local/bin:/opt/local/sbin:${PATH}
      setenv MANPATH /opt/local/share/man:${MANPATH}
      setenv INFOPATH /opt/local/share/info:${INFOPATH}
      setenv PKG_CONFIG_PATH /opt/local/lib/pkgconfig:${PKG_CONFIG_PATH}
  endif

  # Gnuradio source directory (set up for installing gnuradio in $GR/local/)
  setenv GR $HOME/gnuradio
  setenv GR_INSTALL ${GR}/local
  setenv LDFLAGS "-L${GR_INSTALL}/lib ${LDFLAGS}"
  setenv PKG_CONFIG_PATH ${GR_INSTALL}/lib/pkgconfig:${PKG_CONFIG_PATH}
  setenv DYLD_LIBRARY_PATH ${GR_INSTALL}/lib:${DYLD_LIBRARY_PATH}

  # Set up PYTHON variables
  setenv PYTHON_CMD python
  setenv PYTHON_VERSION `${PYTHON_CMD} -V |& sed -e 's@\.@ @2' | awk '{ print $2 }'`
  setenv PYTHON_ROOT `which ${PYTHON_CMD} | sed -e s@/bin/${PYTHON_CMD}@@g`
  setenv PYTHONPATH ${GR_INSTALL}/lib/python${PYTHON_VERSION}/site-packages:${PYTHON_ROOT}/lib/python${PYTHON_VERSION}/site-packages

Many thanks for the help

Raja Sattiraju
  • 1,262
  • 1
  • 20
  • 42
  • Sorry to mention....there are two empty lines at the end of file and now I removed them........but the problem still persists – Raja Sattiraju Jun 06 '12 at 12:17

1 Answers1

1

You want BASH to read and process a set of instructions meant for a different shell! The TCSH has a c-like programming language, where as BASH and SH use some ALGOL-68 like pattern (i think). Bash simply cant process your script.

Use the correct shell for your schript (tcsh/csh) or rewrite your script to bash syntax.

if [ -r /opt/local/bin/port ]
  then
      export LDFLAGS="-L/opt/local/lib ${LDFLAGS}"
      export PATH=${HOME}/bin:/opt/local/bin:/opt/local/sbin:${PATH}
      export MANPATH=/opt/local/share/man:${MANPATH}
      export INFOPATH=/opt/local/share/info:${INFOPATH}
      export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:${PKG_CONFIG_PATH}
  fi

  # Gnuradio source directory (set up for installing gnuradio in $GR/local/)
  export GR=$HOME/gnuradio
  export GR_INSTALL=${GR}/local
  export LDFLAGS="-L${GR_INSTALL}/lib ${LDFLAGS}"
  export PKG_CONFIG_PATH=${GR_INSTALL}/lib/pkgconfig:${PKG_CONFIG_PATH}
  export DYLD_LIBRARY_PATH=${GR_INSTALL}/lib:${DYLD_LIBRARY_PATH}

  # Set up PYTHON variables
  export PYTHON_CMD=python
  export PYTHON_VERSION=`${PYTHON_CMD} -V 2>&1 | sed -e 's@\.@ @2' | awk '{ print $2 }'`
  export PYTHON_ROOT=`which ${PYTHON_CMD} | sed -e s@/bin/${PYTHON_CMD}@@g`
  export PYTHONPATH=${GR_INSTALL}/lib/python${PYTHON_VERSION}/site-packages:${PYTHON_ROOT}/lib/python${PYTHON_VERSION}/site-packages
Mithrandir
  • 24,869
  • 6
  • 50
  • 66
  • Yeah..ur right..Im using the wrong shell. But even after including the lines u mentioned, I still have the same error message.... If I change my shell to tcsh it says LDFLAGS: Undefined Variable – Raja Sattiraju Jun 06 '12 at 12:29
  • 1
    @RajaSattiraju: your envionment is probably build on the basis of bash scripts, at least that's how my Mac works. You're either missing some vital environment variables in you tcsh, that you must provide or you simply rewite your script to bash. – Mithrandir Jun 06 '12 at 12:35
  • Thanks a lot....I will try to set the environment variables first and then see if it executes... else write the script in bash.. – Raja Sattiraju Jun 06 '12 at 12:38
  • I modified the script and ran source and I get the following error messages now – Raja Sattiraju Jun 06 '12 at 12:49
  • -bash: command substitution: line 19: syntax error near unexpected token `&' -bash: command substitution: line 19: `${PYTHON_CMD} -V |& sed -e 's@\.@ @2' | awk '{ print $2 }'' – Raja Sattiraju Jun 06 '12 at 12:49
  • @RajaSattiraju: sorry missed that one, it's tcsh's synatx for piping stderr. in bash you'll have to write 2>&1 | – Mithrandir Jun 06 '12 at 12:54