Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Personal Nodelet Restorer

by $code or die (Deacon)
on Sep 19, 2001 at 22:24 UTC ( [id://113433]=sourcecode: print w/replies, xml ) Need Help??
Category: PerlMonks Related Scripts
Author/Contact Info Simon Flack ($code or die)
Description: This script does the reverse of jeffa's Personal Nodelet Extractor. It is also, mainly his code - so don't bother upvoting this node.

I have needed to re-input all my personal nodelets twice in the last week because I have updated my sig. See this message for more info. This will save me a good 20 minutes next time I have to do it! I need to do some nodelet housekeeping when I have time.

Update: Nov 15 2001 Added modifypn=>'on' to the POST. Also modify and uncomment the line with $ua->proxy if you need it. Thanks ybiC!
#!/usr/bin/perl -w
#Code adapted from

use strict;

use LWP;
use Getopt::Std;
use HTTP::Request::Common;

use vars qw(%opts);

my ($user,$passwd,$nodeletfile) = ($opts{u},$opts{p},$opts{n});
USAGE() and exit unless $user and $passwd and $nodeletfile and not $op

my @nodelets;
open NODELET, $nodeletfile or die "can't open nodelet file: $nodeletfi
+le $!";
while (<NODELET>)
    next unless my ($nodelet) = /^\s*(\d+)/;
    push @nodelets, $nodelet;

use constant URL => '';

my $ua = LWP::UserAgent->new;
$ua->agent('personal_nodlet_restorer/1.0 (' . $ua->agent .')');

#$ua->proxy('http', 'http://myproxy:8080');

# log in and access your User Setting page in raw format
my $request = POST(URL,
    Content => [
        op          => 'login',
        user        => $user,
        passwd      => $passwd,
        node_id     => 1072,
        displaytype => 'raw',
        addtopn        => \@nodelets,
        modifypn    => 'on',

my $response = $ua->request($request);
die $response->message unless $response->is_success;

print "All done. Please double check by logging into PerlMonks with yo
+ur browser";

sub USAGE {
    print "USAGE: $0 -u user -p -password -n nodelet_filename\n";


=head1 NAME - LWP script


Reverses the action of Jeffa's Personal Nodelet Extractor. Given a fil
that contains a list of node_ids, it will log in and add then all to y
personal nodelet.

The majority of this code was shamelessly stolen from Jeffa's Personal
Nodelet Extractor:


for *nix:
./ C<-u> uname C<-p> passwd C<-n> filename 

for win32:
perl C<-u> uname C<-p> passwd C<-n> filena

Invokes the script for the specified username and password. The conten
+ts on the
input file would look something like this:

    24270    Permutations and combinations
    25730    Life in the land of OOP, and I'm confused.
    17890    shift, Pop, Unshift and Push with Impunity!
    32005    Apache::MP3
    34786    Why I like functional programming

It doesn't need a default record seperator - it's collecting all numbe
so a \d+ is sufficient.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://113433]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-25 14:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found