Register
It is currently Mon Sep 01, 2014 7:53 pm

Need help with my script. I can't find the syntax error


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Feb 11, 2011 1:22 am   

Joined: Fri Feb 11, 2011 1:19 am
Posts: 1
Hi everyone,

I have a little bash script:
Code:
#!/bin/sh

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/pkg/cfengine/sbin:/opt/csw/sbin:/opt/csw/bin
export PATH

CFWORKDIR=/var/cfengine

if [ -f /etc/debian_version ]; then
   CFWORKDIR=/var/lib/cfengine2
fi

create_update_conf(){
   #create basic update.conf, meant to update all the config
   #files from the master host

   cat <<EOF | tee $CFWORKDIR/inputs/update.conf $CFWORKDIR/inputs/cfagent.conf
   
   control:
      solaris|solarisx86::
         cf_base_path = ( /opt/csw/sbin )
         workdir = ( /var/cfengine )
         client_cfinput = ( /var/cfengine/inputs )

      debian::
         cf_base_path = ( /usr/sbin )
         workdir = ( /var/lib/cfengine2 )
         client_cfinput = ( /var/lib/cfengine2/inputs )

      redhat::
         cf_base_path = ( /usr/pkg/cfengine/sbin )
         workdir = ( /var/cfengine )
         client_cfinput = ( /var/cfengine/inputs )

      !debian.!redhat.!(solaris|solarisx86)::
         cf_base_path = ( /usr/pkg/cfengine/sbin )
         workdir = ( /var/cfengine )
         client_cfinput = ( /var/cfengine/inputs )

   any::
      actionsequence = ( copy.IfElapsed0
               links.IfElapsed0
               processes.IfElapsed0
             )

   domain = ( local )
   policyhost = ( 192.168.211.136 )
   master_cfinput = ( /var/lib/cfengine2/masterfiles/PROD/inputs )
   SplayTime = ( 0 )

   ignore:
      RCS
      .svn

   processes:
      any::
         #vars with $ at the start must be escaped with \
         "cfexecd" restart "\$(cf_base_path)/cfexecd"
         "cfservd" restart "\$(cf_base_path)/cfservd"
         "cfenvd" restart "\$(cf_base_path)/cfenvd"

   links:
      #debian systems already have a link
      redhat|solaris|solarisx86::
         /var/cfengine/bin/cfagent -> \$(cf_base_path)/cfagent

   copy:
      \$(master_cfinput)/   dest=\$(workdir)/inputs
               r=inf
               mode=700
               type=binary
               exclude=*~
               exclude=#*
               exclude=*,v
               purge=true
               server=\$(policyhost)
               trustkey=true
               encrypt=true

   EOF
}

DIRS="$CFWORKDIR/ppkeys $CFWORKDIR/inputs $CFWORKDIR/bin"
for dir in $DIRS
do
   [ -d $dir ] || mkdir -p $dir && chmod 700 $dir
done

CURRENT_CF_RH_VER=cfengine-2.2.7

if [ -f /etc/redhat-release ]; then
   #need a critical symlink
   if [ -d /usr/pkg/$CURRENT_CF_RH_VER -a ! -d /usr/pkg/cfengine ]; then
      ln -s /usr/pkg/$CURRENT_CF_RH_VER /usr/pkg/cfengine
   fi
fi

if [ ! -f $CFWORKDIR/inputs/update.conf ]; then
   #create_update_conf
   echo "Hallo"
fi

[ -f $CFWORKDIR/ppkeys/localhost.priv ] || cfkey


If I want to run it the terminal says, there is a syntax error on line 102: Syntax error: end of file unexpected (expecting "}")

If I insert a } on line 102 the error still appears. I can't find the error. Can anyone help me? Thanks a lot guys.


Top
 Profile  
 PostPosted: Fri Feb 11, 2011 1:35 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 535
Hi,

your problem is the closing EOF, that needs to be on column 1.
unless you make here-doc word preceded with a -, and you use tabulation for the colsing one.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP