OT: Bash script for Mailman export of email addresses

Nigel Ridley nigel at prayingforisrael.net
Wed Jan 16 04:42:13 UTC 2013


On 01/15/2013 09:43 PM, Nils Kassube wrote:
> Nigel Ridley wrote:
>> On 01/15/2013 09:07 AM, Nils Kassube wrote:
>>> I think you should use the proper values directly where ${whatever}
>>> is used in the script. Otherwise you should use real variable
>>> names without spaces. Something like
>>>
>>> listserv=box220.bluehost.com
>>> listname=somelistname
>>> adminpassword=myverysecretpassword
>>> wget -O - --post-data adminpw=${adminpassword} \
>>> http://${listserv}/admin.cgi/${listname}/members | .....
>>
>> I did use real variable names without spaces:
>> wget -O - --post-data 'adminpw=${myverysecretpassword}'
>> http://${box220.bluehost.com/mailman/admin/mypersonalmailinglist/}/ad
>> min.cgi/${mailinglistname}/members
>>
>> | egrep "_realname" | sed
>> | 's/^.*value="\([^"]*\)".*value="\([^"]*\)".*$/\1,\2/' | sed
>> | 's/%40/@/'
>> |
>>   > maillist.csv
>>
>> Is that what you meant?
>
> No, sorry - I didn't explain it good enough. If you use variables it
> would look like my example above. However it looks like you inserted the
> actual values you want to use between the braces. The expression
> ${WHATEVER} is replaced by the shell with the text stored in the
> variable WHATEVER. But your "variable name"
> "box220.bluehost.com/mailman/admin/mypersonalmailinglist/" is not a
> valid shell variable name and therefore the shell complains.
>
> As your intended action seems to be a one time job, it is not really
> useful to use a lot of variables. Instead you could insert your wanted
> expressions instead. Then the command would look like this:
>
> wget -O - --post-data 'adminpw=myverysecretpassword' \
> http://box220.bluehost.com/mailman/admin/mypersonalmailinglist/admin.cgi/mailinglistname/members | ....
>
> Please note that there are no "$" or braces left in this first part
> of the command.
>
>
> Nils
>

Thanks Nils - that did it:

Connecting to box220.bluehost.com (box220.bluehost.com)|69.89.27.220|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `STDOUT'

     [    <=> 
                                  ] 22,351      28.3K/s   in 0.8s

2013-01-16 06:31:45 (28.3 KB/s) - written to stdout [22351]

The only problem was is that the resulting csv file is empty - 0 bytes. Not sure why.
It doesn't matter anymore as I did it manually by copying and pasting into said empty csv file 
the list of members email addresses and then manipulated them a bit (for some strange reason the 
first email address was in the first column but the rest were in the second column followed by a 
load of 'tab' marks). I simply highlighted the second column, cut and pasted into the first 
column. All the 'tab' marks disappeared and the @ symbol remained as it should (no html entity). 
I then saved it as a csv file (LibreOffice wanted me to save it as an odt file).

So now I have a list of my subscribers ready to import into my soon to be opened account with 
MailChimp.

Thank you for your help,

Nigel




More information about the kubuntu-users mailing list