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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-15-2009, 09:30 PM
|
#1
|
Member
Registered: Nov 2009
Posts: 30
Rep:
|
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.
|
|
|
12-15-2009, 09:39 PM
|
#2
|
Member
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684
Rep:
|
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
|
|
|
12-15-2009, 09:55 PM
|
#3
|
Member
Registered: Nov 2009
Posts: 30
Original Poster
Rep:
|
I tried inserting the "\", but the problem is still there.
Regards
JS
|
|
|
12-15-2009, 10:18 PM
|
#4
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,434
|
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.
|
|
|
12-15-2009, 11:31 PM
|
#5
|
Member
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684
Rep:
|
Just a note, but you can actually just change the shebang line to read: #!/bin/bash -xv as well.
Regards,
Alunduil
|
|
|
12-16-2009, 02:23 AM
|
#6
|
Member
Registered: Nov 2009
Posts: 30
Original Poster
Rep:
|
Thanks all.
|
|
|
All times are GMT -5. The time now is 02:32 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|