me <----- A hard place ------- [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <25425274.20040831151156@Musson.net> [ref] => <327840811.20040831145317@Musson.net> [htmlstate] => on_nl2br [postusername] => Tim [ip] => Tim@Musson.net [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 4 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> How to get config file via http - PERL Beginners

How to get config file via http - PERL Beginners

Hey all, I want to grab a config file from a web server. Basically I need to pull a ServerList.csv from a web server so I don't have to distribute it all over. What module should I use to do that? I did a search on CPAN, but keep getting thousands of responses, and can't seem to find one to do what I want... Thanks! -- Tim Musson Flying with The Bat! eMail v2.12.00 Taxpayer: Someone who doesn't have to take a public service exam to work for the government....

  1. #1

    Default How to get config file via http


    Hey all, I want to grab a config file from a web server. Basically I
    need to pull a ServerList.csv from a web server so I don't have to
    distribute it all over.

    What module should I use to do that? I did a search on CPAN, but keep
    getting thousands of responses, and can't seem to find one to do what
    I want...

    Thanks!

    --
    Tim Musson
    Flying with The Bat! eMail v2.12.00
    Taxpayer: Someone who doesn't have to take a public service exam to
    work for the government.

    Tim Guest

  2. #2

    Default Re: How to get config file via http

    On Tue, 31 Aug 2004, Tim Musson wrote:
     

    Is this a Perl question?

    You could just put ServerList.csv into your web server's doent root
    and serve it directly from Apache or whatever. If you want, you can have
    the web server put a password lock (etc) on the directory that the file
    lives in, or you can just drop it there and forget about it.

    I'm unclear why you'd necessarily have to get Perl involved here.



    --
    Chris Devers com
    http://devers.homeip.net:8080/blog/

    np: 'Sesame Street Theme Song'
    by Sesame Street
    from 'Sesame Street'
    Chris Guest

  3. #3

    Default Re: How to get config file via http

    On Tue, 31 Aug 2004, Chris Devers wrote:
     
    >
    > Is this a Perl question?[/ref]

    Duh, yes, it is -- you said "grab", not "serve". Ignore the last mail.

    The simplest way to do this is in Perl with LWP:

    use LWP::Simple;
    $content = get($URL);

    Or to be more robust about it:

    use LWP::Simple;
    unless (defined ($content = get $URL)) {
    die "could not get $URL\n";
    }

    Make sense?


    --
    Chris Devers com
    http://devers.homeip.net:8080/blog/

    np: 'It's Not Easy Being Green (lo-fi midi version)'
    by Kermit
    from 'The Muppet Movie Soundtrack'
    Chris Guest

  4. #4

    Default Re: How to get config file via http

    Hey Chris,

    My MUA believes you used
    to write the following on Tuesday, August 31, 2004 at 3:03:33 PM.
     [/ref]

    CD> Duh, yes, it is -- you said "grab", not "serve". Ignore the last mail.

    LOL, yep it is. :-)
    Bigger picture. I am processing a list of Windows servers and doing a
    "net view" on each to see if they respond - then presenting an html
    table via a web page. I have the current perl bit on a handfull of
    servers (I don't trust 'em, they are all MS.) I also have the .csv on
    each server, and would like to have it on only a couple (have to have
    redundancy! :-).

    So I am trying to get my 'net_view' perl bit read the server list from
    a web server.

    CD> The simplest way to do this is in Perl with LWP:

    CD> use LWP::Simple;
    CD> $content = get($URL);

    CD> Or to be more robust about it:

    CD> use LWP::Simple;
    CD> unless (defined ($content = get $URL)) {
    CD> die "could not get $URL\n";
    CD> }

    CD> Make sense?

    Yep, I also noticed Net::HTTP. Any reason I should use one over the
    other?

    btw all, thanks for the quick response!

    --
    Tim Musson
    Flying with The Bat! eMail v2.12.00
    ------ A rock -------> me <----- A hard place -------

    Tim Guest

  5. #5

    Default Re: How to get config file via http

    On Tue, 31 Aug 2004, Tim Musson wrote:
     

    The LWP bundle is the primary toolkit for client side web programming
    with Perl. Unless you're doing something more involved -- like the
    things that can be done with WWW::Mechanize and HTTP::Recorder -- the
    LWP toolkit is probably the place to start for this kind of work.

    I mean really, how much simpler can it be than "get($url)" ? :-)

    But read the perldoc for LWP (and the modules it bundles) to get a
    fuller idea of what you can do:

    <http://search.cpan.org/~gaas/libwww-perl-5.800/lib/LWP.pm>


    --
    Chris Devers com
    http://devers.homeip.net:8080/blog/

    np: 'Mahna Mahna!'
    by The Muppets
    from 'The Muppet Show'
    Chris Guest

  6. #6

    Default Re: How to get config file via http

    Hey Chris,

    My MUA believes you used
    to write the following on Tuesday, August 31, 2004 at 3:20:50 PM.

    CD> On Tue, 31 Aug 2004, Tim Musson wrote:
     [/ref]
    ====8<---------------- snip [/ref]

    CD> The LWP bundle is the primary toolkit for client side web programming
    CD> with Perl. Unless you're doing something more involved -- like the
    CD> things that can be done with WWW::Mechanize and HTTP::Recorder -- the
    CD> LWP toolkit is probably the place to start for this kind of work.

    CD> I mean really, how much simpler can it be than "get($url)" ? :-)

    CD> But read the perldoc for LWP (and the modules it bundles) to get a
    CD> fuller idea of what you can do:

    CD> <http://search.cpan.org/~gaas/libwww-perl-5.800/lib/LWP.pm>

    Ok, thanks! I will check it out.

    --
    Tim Musson
    Flying with The Bat! eMail v2.12.00
    What's brown and sticky? ... A stick!

    Tim Guest

  7. #7

    Default Re: How to get config file via http

    Hey Chris,

    My MUA believes you used
    to write the following on Tuesday, August 31, 2004 at 3:20:50 PM.
     [/ref]

    CD> I mean really, how much simpler can it be than "get($url)" ?

    Thanks Chris, I agree, LWP is much simpler. Here is what I am going to
    use. Any other suggestions on cleaning it up?

    ,-----
    | my $URL = "http://localhost/nvh.csv";
    |
    | use LWP::Simple;
    | my $content = get($URL);
    |
    | my lines = split(/\n/, $content);
    |
    | foreach my $line (lines) {
    | # do stuff, for example...
    | print "$line\n";
    | }
    `-----

    --
    Tim Musson
    Flying with The Bat! eMail v2.12.00
    To err is human; To moo is bovine.

    Tim Guest

  8. #8

    Default Re: How to get config file via http

    On Wed, 1 Sep 2004, Tim Musson wrote:
     [/ref]
    >
    > CD> I mean really, how much simpler can it be than "get($url)" ?
    >
    > Thanks Chris, I agree, LWP is much simpler. Here is what I am going to
    > use. Any other suggestions on cleaning it up?
    >
    > ,-----
    > | my $URL = "http://localhost/nvh.csv";
    > |
    > | use LWP::Simple;
    > | my $content = get($URL);
    > |
    > | my lines = split(/\n/, $content);
    > |
    > | foreach my $line (lines) {
    > | # do stuff, for example...
    > | print "$line\n";
    > | }
    > `-----[/ref]

    No, that doesn't look bad.

    The only thing I can suggest is to poke around the other methods that
    are provided by LWP::Simple -- some of them may be able to make work
    easier for you:

    getprint($url); # print $url source to STDOUT
    getstore($url, $file); # store $url to $file
    mirror($url, $file); # store $url to $file if it has changed
    # since the last time you accessed it

    Also, the LWP suite includes some optional command line tools that may
    be worth looking at:

    lwp-download - Fetch large files from the web
    lwp-mirror - Simple mirror utility
    lwp-request - Simple command line user agent
    lwp-rget - Retrieve web doents recursively

    These programs are all written in Perl, so examining their source might
    give you ideas for the kinds of things that can be done.



    --
    Chris Devers com
    http://devers.homeip.net:8080/blog/

    np: 'The Greatest Phone Message of All Time'
    by Jonathan Goldstein
    from 'This American Life: Crimebusters and Crossed Wires'
    Chris Guest

  9. #9

    Default Re: How to get config file via http

    Hey Chris,

    My MUA believes you used
    to write the following on Wednesday, September 1, 2004 at 10:56:13 AM.

    CD> The only thing I can suggest is to poke around the other methods
    CD> that are provided by LWP::Simple -- some of them may be able to
    CD> make work easier for you:

    CD> getprint($url); # print $url source to STDOUT
    CD> getstore($url, $file); # store $url to $file
    CD> mirror($url, $file); # store $url to $file if it has changed
    CD> # since the last time you accessed it

    I am not really going to print the output though. I need to process it
    then print the line in one column of a table with the results of
    another process in another column.

    Thanks for your help!

    --
    Tim Musson
    Flying with The Bat! eMail v2.12.00
    Ever stop to think, and forget to start again?

    Tim Guest

Similar Threads

  1. Replies: 3
    Last Post: June 1st, 02:49 AM
  2. Replies: 6
    Last Post: October 31st, 02:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •