LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-06-2009, 11:52 AM   #1
Toadman
Member
 
Registered: Aug 2002
Location: Copperas Cove, Texas
Distribution: Ubuntu 20.04 LTS
Posts: 304

Rep: Reputation: 21
Spam reporting script was working now fails


I run a script, not written by me, that will take spam and report it to the various abuse addresses. Prior to my upgrade to Mandriva 2010 from 2009.1 this script was working with no issues, now however when trying to run the script I get:

/usr/local/bin/reportSpam: line 1020: syntax error near unexpected token `('
/usr/local/bin/reportSpam: line 1020: ` SUBJECT="$BASE_SUBJECT (${SPAM_IP}) $ORIGINAL_SUBJECT"'


Line 1020 of the script is:

SUBJECT="$BASE_SUBJECT (${SPAM_IP}) $ORIGINAL_SUBJECT"

This probably isn't much help so I've attached the entire script.

Thanks for any advice/assistance.

Chris
Attached Files
File Type: txt reportSpam.txt (35.1 KB, 34 views)
 
Old 12-06-2009, 12:24 PM   #2
gaurav1086
LQ Newbie
 
Registered: Dec 2008
Location: bangalore,india
Distribution: debian lenny
Posts: 13

Rep: Reputation: 0
hello
why are using the parenthesis. Parenthisis is for subshell. remove the parenthesis and it would work fine.
regards.
 
1 members found this post helpful.
Old 12-06-2009, 05:05 PM   #3
Toadman
Member
 
Registered: Aug 2002
Location: Copperas Cove, Texas
Distribution: Ubuntu 20.04 LTS
Posts: 304

Original Poster
Rep: Reputation: 21
Tried that, didn't work:

/usr/local/bin/reportSpam: line 1022: syntax error near unexpected token `('
/usr/local/bin/reportSpam: line 1022: `## NANAS_SUBJECT="[email] (${SPAM_IP}) $ORIGINAL_SUBJECT"'

Removed the parens on line 1022 and get:

/usr/local/bin/reportSpam: line 1092: unexpected EOF while looking for matching `)'
/usr/local/bin/reportSpam: line 1243: syntax error: unexpected end of file

Line 1092 being:

BAD_ADDRS="$(

and there is no line 1243. As I said in my original post this script used to work fine before I upgraded to Mandriva 2010 so something must have changed somewhere but I'll be darned if I can figure it out. I know very little about scripts.
 
Old 12-06-2009, 09:34 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Tried that, didn't work:
Well, it did work, but there was another problem. This one is more interesting, it looks bash's parser fails when faced with a here document piped to command with spaces in it when that is inside a $() substitution. The bash version here is
4.0.28(1)-release, perhaps bash 3.x does not have this problem, which is why the upgrade caused you problems. dash appears to handle this just fine.

Anyways, here is a workaround:
Code:
# change the following lines (1092, 1093)
        BAD_ADDRS="$(
    cat <<-EOF | fold -s -w 64
# to this
        fold_s_w64() { fold -s -w 64; }
        BAD_ADDRS="$(cat <<-EOF | fold_s_w64
 
Old 12-07-2009, 05:18 PM   #5
Toadman
Member
 
Registered: Aug 2002
Location: Copperas Cove, Texas
Distribution: Ubuntu 20.04 LTS
Posts: 304

Original Poster
Rep: Reputation: 21
Sorry to say that didn't work for me. I changed 1092/1093 to:

Code:
fold_s_w64() { fold -s -w 64; }
        BAD_ADDRS="$(cat <<-EOF | fold_s_w64
and still get the line 1020 error:

Code:
/usr/local/bin/reportSpam: line 1020: syntax error near unexpected token `('
/usr/local/bin/reportSpam: line 1020: `    SUBJECT="$BASE_SUBJECT (${SPAM_IP}) $ORIGINAL_SUBJECT"'
 
Old 12-07-2009, 11:48 PM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by Toadman View Post
This probably isn't much help so I've attached the entire script.
Try removing the \c at the end of the echo string on line 747. If that works we can try to figure out why!
 
Old 12-08-2009, 03:02 PM   #7
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by Toadman View Post
and still get the line 1020 error
I was thinking you would apply gaurav1086's fix in addition to mine. Although looking at the script again now, I can't actually see why having parens in a string would be a problem.

Is it possible to install bash 3.x? That would probably be the easiest way to run this script.
 
Old 12-08-2009, 08:00 PM   #8
Toadman
Member
 
Registered: Aug 2002
Location: Copperas Cove, Texas
Distribution: Ubuntu 20.04 LTS
Posts: 304

Original Poster
Rep: Reputation: 21
I've currently got all the changes suggested made to the script, still I get the line 1020 error. Bash reports version

bash --version
GNU bash, version 4.0.33(2)-release (i586-mandriva-linux-gnu)

not sure if I could downgrade to verson 3 though.

I've got dash installed however haven't had a chance to read the manpage. running [chris@localhost ~]$ dash
$ reportSpam
then entering the script name also gives me the same line 1020 error though I may not be doing this correctly. Will have to print out the manpage and look it over.
 
Old 12-09-2009, 10:25 AM   #9
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by Toadman
I've currently got all the changes suggested made to the script, still I get the line 1020 error.
Oh, from your earlier post I assumed that the 1020 error was fixed. Unfortunately I can't reproduce this error in a small script (can't run the whole script because it depends on other things in your system), so I have no idea why it's occuring.

To run the script with dash do
Code:
 $ dash $(which reportSpam)
I assume reportSpam is in your PATH. I don't think dash will be able to run the script as it has less features than bash (eg: doesn't support arrays). I just mentioned it because dash doesn't have a problem with the syntax used on line 1092 (I was able to reproduce that problem in a small script).
 
  


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
spam filter that puts spam into spam folder? paul_mat Linux - Software 3 03-31-2009 04:18 AM
script for deleting spam mails ssilayaraja Linux - Server 1 07-02-2008 07:34 AM
mailq reporting 4000 messages - obviously spam attack genderbender Linux - Security 2 05-18-2007 11:27 PM
Reporting spam by forwarded message broadcast Linux - General 2 03-21-2007 08:51 AM
spam Reporting and Analysis Tools justanothergeek Linux - Software 0 10-12-2004 09:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:17 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