LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-15-2009, 10:30 PM   #1
wjs1990
Member
 
Registered: Nov 2009
Posts: 30

Rep: Reputation: 15
Logging for FTp Daemon


Hi all,
I tried using the following command on a red hat system:

FILE=""
if [ -f /etc/vsftpd.conf ]; then
FILE="/etc/vsftpd.conf"
else
FILE="/etc/vsftpd/vsftpd.conf"
fi
if [ -f $FILE ]; then
awk '/^#?xferlog_std_format/ \
{ print "xferlog_std_format=NO"; next };
/^#?log_ftp_protocol/ \
{ print "log_ftp_protocol=YES"; next };
{ print }' ${FILE}-preCIS > ${FILE}
if [ `egrep -c log_ftp_protocol ${FILE}` == 0 ]; then
echo "log_ftp_protocol=YES" >> ${FILE}
fi
chown root:root $FILE
chmod 0600 $FILE
echo "diff ${FILE}-preCIS $FILE"
diff ${FILE}-preCIS $FILE
else
echo "OK - No /etc/vsftpd.conf."
fi

However, the system return me an error saying, "syntax error near unexpected token `fi'. I suppose the it is trying to say that there are some errors near the last "fi". Any ideas?

Thanks.
 
Old 12-15-2009, 10:39 PM   #2
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
It looks like the problem is a missing \. Please put long code segments in tags in the future, but I think this is what you wanted:

Code:
FILE=""
if [ -f /etc/vsftpd.conf ]; then
  FILE="/etc/vsftpd.conf"
else
  FILE="/etc/vsftpd/vsftpd.conf"
fi
if [ -f $FILE ]; then
  awk '/^#?xferlog_std_format/ \
    { print "xferlog_std_format=NO"; next };
    /^#?log_ftp_protocol/ \
    { print "log_ftp_protocol=YES"; next }; (MISSING \ ?)
    { print }' ${FILE}-preCIS > ${FILE}
  if [ `egrep -c log_ftp_protocol ${FILE}` == 0 ]; then
    echo "log_ftp_protocol=YES" >> ${FILE}
  fi
  chown root:root $FILE
  chmod 0600 $FILE
  echo "diff ${FILE}-preCIS $FILE"
  diff ${FILE}-preCIS $FILE
else
  echo "OK - No /etc/vsftpd.conf."
fi
Regards,

Alunduil
 
Old 12-15-2009, 10:55 PM   #3
wjs1990
Member
 
Registered: Nov 2009
Posts: 30

Original Poster
Rep: Reputation: 15
I tried inserting the "\", but the problem is still there.

Regards
JS
 
Old 12-15-2009, 11:18 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Well, usually it also gives the linenum when that happens. Can you show the exact & entire err msg.
One option for you to try is to put

set -xv

as the 2nd line of your script ie just after the
#!/usr/bin/bash

type line.
The set cmd will show you exactly what's happening.
 
Old 12-16-2009, 12:31 AM   #5
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
Just a note, but you can actually just change the shebang line to read: #!/bin/bash -xv as well.

Regards,

Alunduil
 
Old 12-16-2009, 03:23 AM   #6
wjs1990
Member
 
Registered: Nov 2009
Posts: 30

Original Poster
Rep: Reputation: 15
Thanks all.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Courier not logging in? Auth daemon issue kayasaman Linux - Server 3 10-25-2008 11:48 PM
editing syslog to stop a particular daemon logging hcclnoodles Solaris / OpenSolaris 1 12-05-2006 01:36 PM
ftp daemon doesn't seem to be up!? Chikne Slackware 1 12-05-2006 03:19 AM
Logging with Start stop daemon bigsness Linux - General 0 01-19-2005 04:25 PM
daemon logging- how do I? jimieee Linux - General 1 09-17-2003 10:45 AM


All times are GMT -5. The time now is 07:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration