Unconfigured Ad Widget

Collapse

Special treat for Calguns Linux users

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • #16
    the86d
    Calguns Addict
    • Jul 2011
    • 9592

    Originally posted by vtrigger77
    Whats a linux? Lol
    Linux is a FREE replacement to Windows, and Mac's OSuX.

    It has come a long way from it's roots, but many do not like the applications supported, as typically you can't walk into BestBuy and buy Linux applications like Quickbooks, or Printshop Pro (v.999.21321) for it. You CAN however run a Virtual Machine of Windows inside a Linux Application (best way to state it?) to run Windows software on a Linux box... Wine can run almost any Windows application, but I have yet to mess with that.

    Many who are fed-up with Windows glitches that seem to be ignored by M$, so we seek free alternatives. Open Source software is available for Windows for free too, and usually greatly beneficial. However, Linux Applications can be a little under-featured.

    Comment

    • #17
      ocabj
      Calguns Addict
      • Oct 2005
      • 7924

      Yesterday morning before I went off to a photo shoot, I spent a few minutes in vi and did a quick proof of concept in perl:

      Code:
      #!/usr/bin/perl -w
      use strict;
      use warnings;
      use LWP::UserAgent;
      use HTTP::Request::Common qw(GET);
      use HTML::TableExtract;
      
      my $ua = LWP::UserAgent->new;
      
      my $req = GET 'http://www.powdervalleyinc.com/CCIprimers.shtml';
      
      my $res = $ua->request($req);
      
      if ($res->is_success) {
       my $te = HTML::TableExtract->new( headers => [qw( Item Description Stock Price Buy)] );
       $te->parse($res->content);
      
       foreach my $ts ($te->tables) {
         foreach my $row ($ts->rows) {
           print join(',', @$row), "\n";
         }
       }
      } else {
        print $res->status_line . "\n";
      }
      The output of the above (hardcoded URL) is:

      Code:
      CCI0301 *,CCI U.S. MUSKET CAPS 4-WING REENACTMENT- per 1000,Yes,$64.00, 
      CCI0309 *,CCI #10 PERCUSSION CAPS - per 1000,Out of Stock,$42.50, 
      CCI0310 *,CCI #11 MAG PERCUSSION CAPS - per 1000,Out of Stock,$47.00, 
      CCI0311 *,CCI #11 PERCUSSION CAPS - per 1000,Out of Stock,$42.50, 
      CCI0008 *,CCI 0008 209 TRAP & SKEET PRIMERS CCI - per 1000,Out of Stock,$27.00, 
      CCI0009 *,CCI 0009 209M FIELD PRIMERS - per 1000,Out of Stock,$27.00, 
      CCI34 *,CCI #34 7.62MM MILITARY PRIMERS  (1000),Out of Stock,$38.00, 
      CCI41 *,CCI #41 5.56MM MILITARY PRIMERS  (1000),Out of Stock,$38.00, 
      CCI35 *,CCI #35 50 BMG PRIMERS  (500),Yes,$173.00, 
      CCI300 *,CCI #300 LARGE PISTOL PRIMERS  (1000),Out of Stock,$27.00, 
      CCI350 *,CCI #350 LARGE PISTOL MAGNUM PRIMERS  (1000),Out of Stock,$30.00, 
      CCI200 *,CCI #200 LARGE RIFLE PRIMERS  (1000),Out of Stock,$27.00, 
      CCIBR2 *,CCI BR2 LARGE RIFLE BENCHREST PRIMERS  (1000),Out of Stock,$49.00, 
      CCI250 *,CCI #250 LARGE RIFLE MAGNUM PRIMERS  (1000),Out of Stock,$30.00, 
      CCI500 *,CCI #500 SMALL PISTOL PRIMERS  (1000),Out of Stock,$27.00, 
      CCI550 *,CCI #550 SMALL PISTOL MAGNUM PRIMERS  (1000),Out of Stock,$27.00, 
      CCI400 *,CCI #400 SMALL RIFLE PRIMERS  (1000),Out of Stock,$27.00, 
      CCIBR4 *,CCI BR4 SMALL RIFLE BENCHREST PRIMERS  (1000),Out of Stock,$49.00, 
      CCI450 *,CCI #450 SMALL RIFLE MAGNUM PRIMERS  (1000),Out of Stock,$30.00, 
      CCIA300 *,CCI APS  STRIPS #300 LARGE PISTOL PRIMERS  (1000),Out of Stock,$33.00, 
      CCIA350 *,CCI APS  STRIPS #350 LARGE PISTOL MAG PRIMERS  (1000),Out of Stock,$36.00, 
      CCIA200 *,CCI APS  STRIPS #200 LARGE RIFLE PRIMERS  (1000),Out of Stock,$33.00, 
      CCIABR2 *,CCI APS  STRIPS BR2 LARGE RIFLE BENCHREST PRIMERS  (1000),Out of Stock,$49.00, 
      CCIA250 *,CCI APS  STRIPS #250 LARGE RIFLE MAG PRIMERS  (1000),Out of Stock,$36.00, 
      CCIA500 *,CCI APS  STRIPS #500 SMALL PISTOL PRIMERS  (1000),Out of Stock,$33.00, 
      CCIA550 *,CCI APS  STRIPS #550 SMALL PISTOL MAG PRIMERS  (1000),Out of Stock,$33.00, 
      CCIA400 *,CCI APS  STRIPS #400 SMALL RIFLE PRIMERS  (1000),Out of Stock,$33.00, 
      CCIABR4 *,CCI APS  STRIPS BR4 SMALL RIFLE BENCHREST PRIMERS  (1000),Out of Stock,$49.00, 
      CCIA450 *,CCI APS  STRIPS #450 SMALL RIFLE MAG PRIMERS  (1000),Out of Stock,$36.00,
      I figure it can be written to accept the URL and item numbers through ARGV, that way you can crontab the script multiple times for different Powder Valley product pages and the respective product you want an alert for (look for 'YES' in the In-Stock column/dataset.

      What might not be cool would be to just write this to crawl the entire PV site and then have the script accept only item numbers in ARGV. I doubt you can DoS their site with something like this, but depending on who is analyzing their httpd logs, they might react.

      And it wouldn't be too much of a stretch to simply write the Perl script above to even place an order for you automatically using the LWP perl library when it sees the item you specify in-stock so you don't even have to react to an alert from your script.
      Last edited by ocabj; 07-29-2013, 9:29 AM.

      Distinguished Rifleman #1924
      NRA Certified Instructor (Rifle and Metallic Cartridge Reloading) and RSO
      NRL22 Match Director at WEGC

      https://www.ocabj.net

      Comment

      • #18
        stilly
        I need a LIFE!!
        • Jul 2009
        • 10685

        What is this? a script or something that notifies you when PVI gets things in stock? Would be really cool if it could pop up a messenger body and tell you right then and THERE that things are in.
        7 Billion people on the planet. They aint ALL gonna astronauts. Some will get hit by trains...

        Need GOOD SS pins to clean your brass? Try the new and improved model...



        And remember- 99.9% of the lawyers ruin it for the other .1%...

        Comment

        • #19
          the86d
          Calguns Addict
          • Jul 2011
          • 9592

          Just another benefit to Linux over M$ products...

          Diggin' it more on the daily, not to mention scripts should work with LITTLE modification, unlike .bat(ch) files from version to version of Windows...

          Just out of curiosity, can this send to a local account via sendmail (as I don't think the e-mail server here at work would like to get e-mail from sendmail )? Just use the local account name with nothing after the @ in the script, or <user>@localhost will work? (Remember I am new to the whole Linux on the Desktop...)

          (Time to install Pine?)
          Last edited by the86d; 07-29-2013, 10:13 AM.

          Comment

          • #20
            ocabj
            Calguns Addict
            • Oct 2005
            • 7924

            Originally posted by the86d
            Just out of curiosity, can this send to a local account via sendmail (as I don't think the e-mail server here at work would like to get e-mail from sendmail )? Just use the local account name with nothing after the @ in the script, or <user>@localhost will work? (Remember I am new to the whole Linux on the Desktop...)

            (Time to install Pine?)
            When you use sendmail as a CLI command, you will specify all the parameters including to, from, subject and message. If you want, you can then modify /etc/aliases to just alias local usernames on the system to external email addresses for the sake of recipients.

            Distinguished Rifleman #1924
            NRA Certified Instructor (Rifle and Metallic Cartridge Reloading) and RSO
            NRL22 Match Director at WEGC

            https://www.ocabj.net

            Comment

            • #21
              ocabj
              Calguns Addict
              • Oct 2005
              • 7924

              Here's another way to go about it to generalize a script for single item checks and to return POSIX-style codes.

              Code:
              #!/usr/bin/perl -w
              use strict;
              use warnings;
              use LWP::UserAgent;
              use HTTP::Request::Common qw(GET);
              use HTML::TableExtract;
              
              if (scalar @ARGV < 1) {
                print "Usage: pv.pl <item>\n";
                exit 2;
              }
              
              our @wishlist = @ARGV;
              our @pvurls = (
              		"http://www.powdervalleyinc.com/CCIprimers.shtml",
              		"http://www.powdervalleyinc.com/TULprimers.shtml"
              		);
              
              sub instock() {
                my $price = pop(@_);
                my $avail = pop(@_);
                my $desc = pop(@_);
                my $item = pop(@_);
              
                foreach (@wishlist) {
                  if ($_ =~ /$item/i) {
                    if ($avail =~ /yes/i) {
                      print $desc . " are in-stock!\n";
              	exit 0;
                    } else {
                      print $desc . " are out-of-stock.\n";
                      exit 1;
                    }
                  }
                }
              }
              
              my $ua = LWP::UserAgent->new;
              
              foreach my $pvurl (@pvurls) {
                my $req = GET $pvurl;
                my $res = $ua->request($req);
              
                if ($res->is_success) {
                 my $te = HTML::TableExtract->new( headers => [qw( Item Description Stock Price)] );
                 $te->parse($res->content);
                 foreach my $ts ($te->tables) {
                   foreach my $row ($ts->rows) {
                     &instock(@$row);
                   }
                 }
                } else {
                  print $res->status_line . "\n";
                  exit 3;
                }
              }
              
              exit 4;
              0 code would mean in-stock, 1 code out-of-stock, and anything else would be designated for errors.

              Naturally, instead of exiting out, you could just internalize everything as returns instead of exits to chain subroutines and control structures for other things (e.g. if item not out-of-stock, return non-zero; on non-zero, execute subroutine to submit an order for X amount of item).

              Sample output:
              Code:
              $ ./pv.pl TULSP
              TUL SMALL PISTOL PRIMERS (KVB9)  (1000) are in-stock!
              $ echo $?
              0
              $ ./pv.pl cci500
              CCI #500 SMALL PISTOL PRIMERS  (1000) are out-of-stock.
              $ echo $?
              1

              Distinguished Rifleman #1924
              NRA Certified Instructor (Rifle and Metallic Cartridge Reloading) and RSO
              NRL22 Match Director at WEGC

              https://www.ocabj.net

              Comment

              • #22
                RM14
                Junior Member
                • Feb 2013
                • 84

                Originally posted by rjpsb1
                Post #4 said use backticks. I didn't say you did. But thanks for the hostility.
                My point was more to avoid using eval for shell command execution, regardless of input data or not. Whether you use backticks, or $() properly, is up to you, I just advise against using eval at all costs, as that is more a sign of defeat.
                "Every absurdity has a champion to defend it." -Oliver Goldsmith

                Comment

                Working...
                UA-8071174-1