3 Replies Latest reply on Jun 1, 2006 7:25 AM by Sung Koo

    Verifying a successful deployment using telnet

      We have 3rd party software that is used to look up postcodes and validate addresses. There are regular monthly data updates and I need to verify that the update has been successful. Currently this is doine by logging onto the server, telneting to the localhost on port 20000, issuing a 'GET' command and checking the returned results.


      1. telnet localhost 20000


      GET /uk?sortcode=600427&account=1234567


      Connection closed by foreign host.



      Is it possible to do this as part of the BL package and if so, how do I set about doing it?

        • 1. Re: Verifying a successful deployment using telnet

          There are lots of ways to do this.


          You could use the "wget" utility or the perl "lwp" module to dump this data. That would be easiest. If you know expect, you could just wrap an expect script around your telnet session. Python has some modules that does this too. It really depends on what tools you have access to.


          Might be useful to make this an extended object rather than executing this via a package.

          • 2. Re: Verifying a successful deployment using telnet

            Thanks for the reply, Sung.


            I'm not too familiar with wget or lwp - could you give me a little more info on how to get started?

            • 3. Re: Verifying a successful deployment using telnet

              Wget is a Unix/GNU utility that just downloads whatever you point it at. If you want to grab your http content from localhost and dump it to a file, you can just execute:



              wget http://localhost:20000/uk?sortcode=600427&account=1234567


              With LWP, it's a little more complicated, but you can parse the output with Perl, and that's always nice. You can just use it as a command line utility too. For example:



              perl -MLWP::Simple -e "getprint 'http://localhost:20000/STUFF'"


              This will just dump the content to stdout.


              Getting LWP to do some more interesting stuff gets a bit more complicated. You can tokenize HTML tags and return data to an array, you can recurse and parse web content, etc. I use to use it to check content on critical web sites with dynamic content and it was a godsend.


              Here's a bit of sample code for downloading content from an site then parsing. It's not horribly compex and it doesn't show it's extensability, but it is a nice intro. I copied it from http://www.perl.com/pub/a/2002/08/20/perlandlwp.html


              my $browser = LWP::UserAgent->new;


              # Then later, whenever you need to make a get request:
              my $url = 'http://freshair.npr.org/dayFA.cfm?todayDate=current';

              my $response = $browser->get( $url );
              die "Can't get $url -- ", $response->status_line
              unless $response->is_success;

              die "Hey, I was expecting HTML, not ", $response->content_type
              unless $response->content_type eq 'text/html';
              # or whatever content-type you're equipped to deal with

              # Otherwise, process the content somehow:

              if($response->content =~ m/jazz/i) {
              print "They're talking about jazz today on Fresh Air!\n";
              } else {
              print "Fresh Air is apparently jazzless today.\n";