LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 09: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, 09: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, 09: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, 10:18 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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-15-2009, 11:31 PM   #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, 02:23 AM   #6
wjs1990
Member
 
Registered: Nov 2009
Posts: 30

Original Poster
Rep: Reputation: 15
Thanks all.
 
  


Reply



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 10:48 PM
editing syslog to stop a particular daemon logging hcclnoodles Solaris / OpenSolaris 1 12-05-2006 12:36 PM
ftp daemon doesn't seem to be up!? Chikne Slackware 1 12-05-2006 02:19 AM
Logging with Start stop daemon bigsness Linux - General 0 01-19-2005 03:25 PM
daemon logging- how do I? jimieee Linux - General 1 09-17-2003 09:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:45 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
Open Source Consulting | Domain Registration