3

when i build shell script am getting the below error, since am new to CentOS am not able to find out the cause can anyone help me regarding this ??

I guess we need to pass command line parameter while executing am not sure what has to be passed as parameter here.

Shell-script :

#!/bin/sh

# Default place to look for apr source.  Can be overridden with
#   --with-apr=[directory]
apr_src_dir=../apr

while test $# -gt 0
do
  # Normalize
  case "$1" in
  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  *) optarg= ;;
  esac

  case "$1" in
  --with-apr=*)
  apr_src_dir=$optarg
  ;;
  esac

  shift
done

if test -d "$apr_src_dir"
then
  echo ""
  echo "Looking for apr source in $apr_src_dir"
else
  echo ""
  echo "Problem finding apr source in $apr_src_dir."
  echo "Use:"
  echo "  --with-apr=[directory]"
  exit 1
fi

# Remove some files, then copy them from apr source tree
rm -f build/apr_common.m4 build/find_apr.m4 build/install.sh \
      build/config.guess build/config.sub build/mkdir.sh \
      build/make_exports.awk build/make_var_export.awk \
      build/get-version.sh
cp $apr_src_dir/build/apr_common.m4 $apr_src_dir/build/find_apr.m4 \
   $apr_src_dir/build/install.sh $apr_src_dir/build/config.guess  \
   $apr_src_dir/build/config.sub $apr_src_dir/build/mkdir.sh \
   $apr_src_dir/build/make_exports.awk $apr_src_dir/build/make_var_export.awk \
   $apr_src_dir/build/get-version.sh \
   build

Error obtained :

[root@localhost apr-iconv]# sh buildconf 
buildconf: line 2: $'\r': command not found
buildconf: line 6: $'\r': command not found
buildconf: line 10: syntax error near unexpected token `$'in\r''
'uildconf: line 10: `  case "$1" in

Thank you :)

amb
  • 93
  • 1
  • 7
  • 4
    It sound like your file is saved with Windows line endings. See e.g. https://stackoverflow.com/questions/2613800/how-to-convert-dos-windows-newline-crlf-to-unix-newline-lf-in-a-bash-script on how to convert your file. – nos Aug 10 '18 at 12:44
  • hey thanks a lot. It worked after converting it into unix format. – amb Aug 16 '18 at 11:56

1 Answers1

5

This error got cleared once shell-script is changed to Unix format. That conversion you can do by executing the command dos2unix <file-name>. If have to install dos2unix to avoid error 'dos2unix: command not found'.

amb
  • 93
  • 1
  • 7