Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] Sum a particular column.

Expand Messages
  • Wright, William
    A possible solution with perl... #!/usr/bin/perl -w use strict; my $sum; # where you ll hold the result while ( ) # reads from stdin { chomp;
    Message 1 of 4 , Jul 24, 2002
    • 0 Attachment
      A possible solution with perl...

      #!/usr/bin/perl -w
      use strict;
      my $sum; # where you'll hold the result
      while (<>) # reads from stdin
      {
      chomp; # get rid of end of line characters
      my @cols = split /\s+/; # split the input line on whitespace
      $sum += $cols[1]; # now you have an array of the fields on the
      # line starting with index 0 in @cols
      }
      print "toatl is: $sum\n";

      keep in mind that if columns have headers then you'll need to skip them
      somehow...
      maybe....
      $sum += $cols[1] if $cols[1] =~ m/^\d+$/; # says that only sum if $cols[1]
      is all digit characters.

      theres probally a shorter way to do the same thing but this is a pretty
      simple-minded approach to the problem.


      -----Original Message-----
      From: Subodh [mailto:subodh.gupta@...]
      Sent: Wednesday, July 24, 2002 1:25 AM
      To: perl-beginner@yahoogroups.com
      Subject: [PBML] Sum a particular column.


      Hi All,

      It would be of great help if someone can tell me how to get the sum of a
      particular column in a shell script.

      for eg. if the contents of my file are:

      col1 col2
      Type1 10
      Type2 20

      and I want to get the sum of col2, then the result should give me 30. How
      is this possible?

      I hardly have any experience in writing shell scripts.. so please help me.

      Subodh Gupta

      -------------------------------------------------
      Sify Mail - now with Anti-virus protection powered by Trend Micro, USA.
      Know more at http://mail.sify.com

      One click here and you could be counting money!
      StreetsCall from Walletwatch.com. Subscribe now!
      http://www.walletwatch.com/cgi-bin/ww/walletwatch/equity/news_articles/news_
      detail.jsp?oid=11658894


      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    • frankie
      Hi people... Does anyone here know anything about the env variable http_referer ??? for some reason our ssl server doesn t provide a $ENV{ HTTP_REFERER } when
      Message 2 of 4 , Jul 24, 2002
      • 0 Attachment
        Hi people...

        Does anyone here know anything about the env variable http_referer ???

        for some reason our ssl server doesn't provide a $ENV{'HTTP_REFERER'} when
        called through ssl, but it does
        when called without ssl..

        I put a page on the server in ssl with a link to a env printing perl script
        on another server.. when you go to that page via ssl, the referer is empty,
        but if you click the link via standard http, the referer is there..

        I don't understand why.. is it something to do with our firewall? (we have
        port 443 port forwarded from the firewall/router to 443 on the ssl
        server...)

        serching the net doesn't seem to find much..

        If I can't fix the problem, is there a way to manually add the referer to
        any requests sent from that box?


        Is this something that was changed in the IIS settings? I can find nothing
        in there that would change this... so I'm a tad lost.. (the server is
        win2000 with fully patched IIS5)

        any tips would be fantastic...

        rgds

        Frank
      • b_harnish
        ... That sounds like the way I believe it should work. _ALL_ traffic to the https page is encrypted, including the URL. If i left that encrypted page, why
        Message 3 of 4 , Jul 26, 2002
        • 0 Attachment
          --- In perl-beginner@y..., "frankie" <frankieh@i...> wrote:
          > Hi people...
          >
          > Does anyone here know anything about the env variable http_referer ???
          >
          > for some reason our ssl server doesn't provide a $ENV{'HTTP_REFERER'} when
          > called through ssl, but it does
          > when called without ssl..
          >
          > I put a page on the server in ssl with a link to a env printing perl script
          > on another server.. when you go to that page via ssl, the referer is empty,
          > but if you click the link via standard http, the referer is there..
          >
          > I don't understand why.. is it something to do with our firewall? (we have
          > port 443 port forwarded from the firewall/router to 443 on the ssl
          > server...)

          That sounds like the way I believe it should work. _ALL_ traffic to the https page is encrypted, including the URL. If i left that encrypted page, why would I want that URL to be sent in cleartext? That URL could have my account info in the query string.

          So, I believe the answer to your question is: "It's by design."

          - Brian "the paranoid"
          I'd stop being paranoid, but thats just what they want me to do.
        • frankie
          yup, you are probably right.. but its really dumb that so many security protocols are partially circumvented by security for example, scripts that use
          Message 4 of 4 , Jul 27, 2002
          • 0 Attachment
            yup,

            you are probably right.. but its really dumb that so many security protocols
            are partially circumvented by "security"

            for example, scripts that use referer as a way of making sure that requests
            are coming from where they are expected from

            people load zone alarm and it all falls in a heap because zone alarm has
            stopped any info at all from getting out..


            Like with CGI scripts.. I try to make it so that when a user goes to one of
            the scripts, they are assigned an ID, and that ID is associated with their
            IP address, and a cookie is set as well.. and from that point on, that ID
            can only be used by that IP address. its a flawed security method, because
            IP's can be spoofed (and cookies may be disabled). but its certainly better
            then nothing because it takes time and skill to get around that. Something
            that most script kiddies lack.

            And if they (users) have Zonealarm or another soft firewall, (or worse, they
            use AOL) the script breaks.

            Does anyone have any ideas or sources for tracking users that would be of
            help in this regard?

            One last point, the Web server at the other end of the SSL request knows the
            IP address of the requesting client, so I would have thought that it would
            be available to the perl scritp as well. and if a url string is sent from a
            SSL connection to a non SSL connection, wouldn't the string to the non SSL
            have to be cleartext for it to be received correctly?


            thanks for speaking up, much appreciated.



            rgds

            Frank
            -----Original Message-----
            From: b_harnish [mailto:bharnish@...]
            Sent: Saturday, July 27, 2002 5:42 AM
            To: perl-beginner@yahoogroups.com
            Subject: [PBML] Re: HTTP_REFERER


            --- In perl-beginner@y..., "frankie" <frankieh@i...> wrote:
            > Hi people...
            >
            > Does anyone here know anything about the env variable http_referer ???
            >
            > for some reason our ssl server doesn't provide a $ENV{'HTTP_REFERER'} when
            > called through ssl, but it does
            > when called without ssl..
            >
            > I put a page on the server in ssl with a link to a env printing perl
            script
            > on another server.. when you go to that page via ssl, the referer is
            empty,
            > but if you click the link via standard http, the referer is there..
            >
            > I don't understand why.. is it something to do with our firewall? (we have
            > port 443 port forwarded from the firewall/router to 443 on the ssl
            > server...)

            That sounds like the way I believe it should work. _ALL_ traffic to the
            https page is encrypted, including the URL. If i left that encrypted page,
            why would I want that URL to be sent in cleartext? That URL could have my
            account info in the query string.

            So, I believe the answer to your question is: "It's by design."

            - Brian "the paranoid"
            I'd stop being paranoid, but thats just what they want me to do.



            Unsubscribing info is here:
            http://help.yahoo.com/help/us/groups/groups-32.html

            Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
          Your message has been successfully submitted and would be delivered to recipients shortly.