Perl Gurus - need a script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Smegma
    Confirmed User
    • Feb 2002
    • 1751

    #1

    Perl Gurus - need a script

    Need a quick script written in Perl.

    The only thing it should do is display the following in a web-browser.

    "This Mail Client is Unavailable. Please select another. "

    Anyone?
    <a href="http://www.jupiterhosting.com"><img src="http://www.jupiterhosting.com/banners/55x55.jupiter.gif" alt="" border="0" align=""></a>
  • DrGuile
    Confirmed User
    • Jan 2002
    • 2025

    #2
    why perl?

    PHP Code:
    echo "This emails is unavailable... blabla"; 
    
    LiveBucks / Privatefeeds - Giving you money since 1999
    Up to 50% Commission!
    25% Webmaster Referal
    Powered by Gamma

    Comment

    • vending_machine
      Confirmed User
      • Jun 2002
      • 1070

      #3
      Why Perl/PHP? Why not straight HTML....

      Comment

      • Smegma
        Confirmed User
        • Feb 2002
        • 1751

        #4
        Hard coded URL to a perl file.. can't change.
        <a href="http://www.jupiterhosting.com"><img src="http://www.jupiterhosting.com/banners/55x55.jupiter.gif" alt="" border="0" align=""></a>

        Comment

        • DrGuile
          Confirmed User
          • Jan 2002
          • 2025

          #5
          you can make .cgi or .pl file be parsed by php.. .or be considered html files...


          Think outside the box ;p
          LiveBucks / Privatefeeds - Giving you money since 1999
          Up to 50% Commission!
          25% Webmaster Referal
          Powered by Gamma

          Comment

          • nuclei
            old school fart
            • May 2001
            • 1015

            #6
            #!/usr/bin/perl

            use CGI ':cgi';

            print header;
            print "This Mail Client is Unavailable. Please select another.\n";
            exit;


            the above is to display in a web browser. to display as plain text in anything BUT a browser:

            #!/usr/bin/perl

            print "This Mail Client is Unavailable. Please select another.\n";
            exit;
            The next generation of SEO

            Comment

            • salsbury
              Confirmed User
              • Feb 2002
              • 1070

              #7
              this one will auto-detect if it is running from a web hit (note that it isn't the best way. given more time, i would have incorporated references, but it does work as it is)

              #!/usr/bin/perl
              #
              # prints the text
              # "This Mail Client is Unavailable. Please select another. "
              # and exits.

              # make sure we're not slipping up
              use strict;

              my $OUT_STRING = '"This Mail Client is Unavailable. Please select another."';

              # support sub-routines

              # returns the character, for addition to a buffer
              sub bufferChar ($) {
              my ($char) = @_;
              return $char;
              }

              sub bufferLine ($) {
              my ($line) = @_;
              my $out;
              foreach my $char (split (//, $line)) {
              $out .= &bufferChar ($char);
              }
              $out .= &bufferChar ("\n");
              return $out;
              }

              # main program

              # overall output
              my $output;

              my $line_output = &bufferLine ($OUT_STRING);

              # verify if we're running from a web request
              if ($ENV{'REQUEST_METHOD'}) {
              # we are, we need to print headers
              my $headers = &bufferLine ("Content-type: text/plain");
              $headers .= &bufferLine ("Content-length: " . (length ($line_output)));
              $headers .= &bufferLine ("");
              print $headers;
              }
              print $line_output;

              exit 0;

              Comment

              • nuclei
                old school fart
                • May 2001
                • 1015

                #8
                haha nice spaghetti code there, took how many lines to do exactly what the 3 or 4 line scripts i pasted do?
                The next generation of SEO

                Comment

                • vending_machine
                  Confirmed User
                  • Jun 2002
                  • 1070

                  #9
                  Originally posted by nuclei
                  haha nice spaghetti code there, took how many lines to do exactly what the 3 or 4 line scripts i pasted do?
                  I think you need to see my signature, think about it for about 120 minutes, and then come back. Mkaye?

                  Comment

                  • salsbury
                    Confirmed User
                    • Feb 2002
                    • 1070

                    #10
                    Originally posted by nuclei
                    haha nice spaghetti code there, took how many lines to do exactly what the 3 or 4 line scripts i pasted do?
                    oh suure, you and your high and mighty "use CGI" and simple "print" statements doing all the work for you. why, back in my day, things were hard, and we were damn glad for it.

                    Comment

                    • nuclei
                      old school fart
                      • May 2001
                      • 1015

                      #11
                      does what hurt exactly?

                      that it took someone about 30 lines for a bone dry 3-4 line script?

                      not at all =)
                      The next generation of SEO

                      Comment

                      • nuclei
                        old school fart
                        • May 2001
                        • 1015

                        #12
                        Originally posted by salsbury


                        oh suure, you and your high and mighty "use CGI" and simple "print" statements doing all the work for you. why, back in my day, things were hard, and we were damn glad for it.
                        heh, I have been here under the same name for a lotta years mate, I was here before CGI.pm. But as for lettin git do the work, hell yes as its 50x faster.

                        as for the "simple print statements" jibe:

                        print $headers;
                        }
                        print $line_output;

                        yers does the exact same thing, it just takes you 30 lines to build print "whatever he wanted printed\n";
                        Last edited by nuclei; 12-19-2002, 03:24 PM.
                        The next generation of SEO

                        Comment

                        • salsbury
                          Confirmed User
                          • Feb 2002
                          • 1070

                          #13
                          Originally posted by nuclei


                          heh, I have been here under the same name for a lotta years mate, I was here before CGI.pm. But as for lettin git do the work, hell yes as its 50x faster.
                          ha ha. if it isn't paaaainfully obvious yet, i wrote that as a joke. however, in any case, you might want to compare the two for speed. run each 100 times:

                          x=0;time while [ $x -lt 100 ];do
                          ./salsbury.script
                          x=$((x+1))
                          done

                          (edit: forgot to increment $x. ha ha.)

                          and then ./nuclei.script

                          i did that, and found mine to be 833% faster. and mind is breaking the goddamn line up and then putting it back together again piece by piece!! of course, it would have been faster with references, but those are tricky sometimes.

                          "use CGI" takes up an inordinate amount of CPU time.
                          Last edited by salsbury; 12-19-2002, 03:30 PM.

                          Comment

                          • Smegma
                            Confirmed User
                            • Feb 2002
                            • 1751

                            #14
                            Thanks! it worked.
                            <a href="http://www.jupiterhosting.com"><img src="http://www.jupiterhosting.com/banners/55x55.jupiter.gif" alt="" border="0" align=""></a>

                            Comment

                            • wwwcashmountain
                              Confirmed User
                              • Dec 2002
                              • 194

                              #15
                              10 print "This Mail Client is Unavailable. Please select another. "
                              20 goto 10
                              SIG TOO BIG! Maximum 120x60 button and no more than 3 text lines of DEFAULT SIZE and COLOR. Unless your sig is for a GFY top banner sponsor, then you may use a 624x80 instead of a 120x60.

                              Comment

                              • nuclei
                                old school fart
                                • May 2001
                                • 1015

                                #16
                                It does huh?

                                [root@ns1 /root]# time ./obfuscated.pl
                                0:00.59elapsed 13%CPU

                                [root@ns1 /root]# time ./mine.pl
                                0:00.09elapsed 8%CPU


                                oooookay
                                The next generation of SEO

                                Comment

                                • nuclei
                                  old school fart
                                  • May 2001
                                  • 1015

                                  #17
                                  now lets see, multiply that by 100 right?
                                  The next generation of SEO

                                  Comment

                                  • salsbury
                                    Confirmed User
                                    • Feb 2002
                                    • 1070

                                    #18
                                    Originally posted by nuclei
                                    It does huh?

                                    [root@ns1 /root]# time ./obfuscated.pl
                                    0:00.59elapsed 13%CPU

                                    [root@ns1 /root]# time ./mine.pl
                                    0:00.09elapsed 8%CPU


                                    oooookay
                                    you gotta run it more than once man. like, 100 times, like i suggested. or did that show exactly what i said it would?

                                    salsbury@root:/home/salsbury$ x=0;time while [ $x -lt 100 ];do ./salsbury > /dev/null; x=$((x+1));done
                                    1.64s real 0.01s user 0.05s system

                                    salsbury@root:/home/salsbury$ x=0;time while [ $x -lt 100 ];do ./nuclei > /dev/null; x=$((x+1));done
                                    13.04s real 0.10s user 0.06s system

                                    Comment

                                    • DirkPitt
                                      Confirmed User
                                      • Sep 2002
                                      • 357

                                      #19
                                      How do I write to a data base or text file in perl from a form or a link?
                                      Thanks,
                                      Kit

                                      Comment

                                      • nuclei
                                        old school fart
                                        • May 2001
                                        • 1015

                                        #20
                                        Originally posted by salsbury


                                        you gotta run it more than once man. like, 100 times, like i suggested. or did that show exactly what i said it would?

                                        salsbury@root:/home/salsbury$ x=0;time while [ $x -lt 100 ];do ./salsbury > /dev/null; x=$((x+1));done
                                        1.64s real 0.01s user 0.05s system

                                        salsbury@root:/home/salsbury$ x=0;time while [ $x -lt 100 ];do ./nuclei > /dev/null; x=$((x+1));done
                                        13.04s real 0.10s user 0.06s system

                                        oh so if i run it 100 times its going to be faster.. umm think about what you just said mate.

                                        if its slower just running it once.....

                                        I mean face it, the guy aint going to run it 100 times everytime he needs it to spit out that line now is he?
                                        Last edited by nuclei; 12-19-2002, 03:44 PM.
                                        The next generation of SEO

                                        Comment

                                        • nuclei
                                          old school fart
                                          • May 2001
                                          • 1015

                                          #21
                                          Originally posted by DirkPitt
                                          How do I write to a data base or text file in perl from a form or a link?
                                          you use a form handling script. I would not suggest matts formmail tho :P
                                          The next generation of SEO

                                          Comment

                                          • salsbury
                                            Confirmed User
                                            • Feb 2002
                                            • 1070

                                            #22
                                            Originally posted by DirkPitt
                                            How do I write to a data base or text file in perl from a form or a link?
                                            take my code (or nuclei's) and add:

                                            open (OUTPUT, ">output.text.tmp") || die "output.text.tmp: $!";
                                            close (OUTPUT);

                                            around it. then replace every 'print' line with

                                            $FINAL_OUTPUT .=

                                            then, add before the close OUTPUT line:

                                            $FINAL_LENGTH = length ($FINAL_OUTPUT);
                                            print OUTPUT $FINAL_OUTPUT;

                                            after the close (OUTPUT);

                                            if (-s "output.text.tmp" == $FINAL_LENGTH) {
                                            rename ("output.text.tmp", "output.text") || die "rename output.text.tmp output.text: $!";
                                            }

                                            and you're done! wala!

                                            Comment

                                            • salsbury
                                              Confirmed User
                                              • Feb 2002
                                              • 1070

                                              #23
                                              Originally posted by nuclei
                                              oh so if i run it 100 times its going to be faster.. umm think about what you just said mate.

                                              if its slower just running it once.....
                                              that's right, it will be faster. running it once won't show you jack shit. that's like a scientist running an experiment once and declaring it absolute truth.

                                              btw:

                                              From WordNet (r) 1.7 [wn]:

                                              overhead
                                              2: (computer science) the processing time required by a device
                                              prior to the execution of a command [syn: {command
                                              processing overhead time}, {command processing overhead},
                                              {command overhead}]

                                              From The Free On-line Dictionary of Computing (09 FEB 02) [foldoc]:

                                              overhead

                                              1. Resources (in computing usually processing time or storage
                                              space) consumed for purposes which are incidental to, but
                                              necessary to, the main one. Overheads are usually
                                              quantifiable "costs" of some kind.

                                              Comment

                                              • nuclei
                                                old school fart
                                                • May 2001
                                                • 1015

                                                #24
                                                Originally posted by salsbury


                                                that's right, it will be faster. running it once won't show you jack shit. that's like a scientist running an experiment once and declaring it absolute truth.

                                                btw:

                                                From WordNet (r) 1.7 [wn]:

                                                overhead
                                                2: (computer science) the processing time required by a device
                                                prior to the execution of a command [syn: {command
                                                processing overhead time}, {command processing overhead},
                                                {command overhead}]

                                                From The Free On-line Dictionary of Computing (09 FEB 02) [foldoc]:

                                                overhead

                                                1. Resources (in computing usually processing time or storage
                                                space) consumed for purposes which are incidental to, but
                                                necessary to, the main one. Overheads are usually
                                                quantifiable "costs" of some kind.

                                                mate, I dont wanna start a war with ya, yer code works, however, his program calling it is only going to run it one time for each instance it is called. In which case my code is faster with less overhead (CPU usage).

                                                calling it 100 times isnt going to mean a damn thing to him as his use only requires it running once.
                                                Last edited by nuclei; 12-19-2002, 03:49 PM.
                                                The next generation of SEO

                                                Comment

                                                • salsbury
                                                  Confirmed User
                                                  • Feb 2002
                                                  • 1070

                                                  #25
                                                  Originally posted by nuclei


                                                  mate, I dont wanna start a war with ya, yer code works, however, his program calling it is only going to run it one time for each instance it is called. In which case my code is faster with less overhead (CPU usage).

                                                  calling it 100 times isnt going to mean a damn thing to him as his use only requires it running once.
                                                  oh so it's war you want?

                                                  Comment

                                                  • nuclei
                                                    old school fart
                                                    • May 2001
                                                    • 1015

                                                    #26
                                                    hmm ok I ran the same test 10 times (one at a time, the same as his need is) with the only differance being a .01 change in 2 tests.

                                                    Now i can say it is truth.
                                                    The next generation of SEO

                                                    Comment

                                                    • salsbury
                                                      Confirmed User
                                                      • Feb 2002
                                                      • 1070

                                                      #27
                                                      Originally posted by nuclei
                                                      hmm ok I ran the same test 10 times (one at a time, the same as his need is) with the only differance being a .01 change in 2 tests.

                                                      Now i can say it is truth.
                                                      damn. well, all i can say now is we're some damn fine perl programmers. i'd say we've got this problem licked! i think lensman should make this topic sticky just in case anyone else needs to print a single line using a perl CGI script (or even non-CGI).

                                                      Comment

                                                      • nuclei
                                                        old school fart
                                                        • May 2001
                                                        • 1015

                                                        #28
                                                        hahahaha

                                                        look me up if you have some spare time and want some extra cash mate :P

                                                        I assume you can use CGI even if you like arguing against it =)
                                                        The next generation of SEO

                                                        Comment

                                                        • DirkPitt
                                                          Confirmed User
                                                          • Sep 2002
                                                          • 357

                                                          #29
                                                          You guys ever Use iBills ref variables. Do you know the perl code that writes your new member's email to a mysql data base or a .txt file? I'm looking for the complete perl code on your server not iBill's.
                                                          Thanks,
                                                          Kit

                                                          Comment

                                                          • nuclei
                                                            old school fart
                                                            • May 2001
                                                            • 1015

                                                            #30
                                                            Originally posted by DirkPitt
                                                            You guys ever Use iBills ref variables. Do you know the perl code that writes your new member's email to a mysql data base or a .txt file? I'm looking for the complete perl code on your server not iBill's.
                                                            Salsbury showed you how to write it to a file.
                                                            The next generation of SEO

                                                            Comment

                                                            • The Truth Hurts
                                                              Zph7YXfjMhg
                                                              • Nov 2002
                                                              • 15744

                                                              #31
                                                              Jesus Fucking Christ nuclei...

                                                              I guess there's a good reason it's "PerlCoders" and not "JavaScriptCoders".

                                                              Just navigating around that fucker I ended up with 11 instances of the same fucking "PerlCoders Member Benefits" popup, plus the "guided tour" popup, plus the "profitscripts.com" popup, plus the main window I originally went in with.

                                                              WHAT THE FUCK?!?!

                                                              Comment

                                                              • nuclei
                                                                old school fart
                                                                • May 2001
                                                                • 1015

                                                                #32
                                                                Only place you get *any* popups is the free script page. and the only way you can get the guided tour popup window is to CLICK the guided tour links. what browser are you using??
                                                                The next generation of SEO

                                                                Comment

                                                                • KC
                                                                  Confirmed User
                                                                  • Jan 1995
                                                                  • 2417

                                                                  #33
                                                                  Jesus Christ..

                                                                  He just wants a script to print out a single string.

                                                                  Why does everyone want to complicate things?? He doesn't need a custom daemon built to handle it, it doesn't need air conditioning and heated seats..

                                                                  Simple is better!!!! ;)

                                                                  Jupiter Hosting, Inc.
                                                                  Vice President, Business Development
                                                                  kc (AT) jupiterhosting.com

                                                                  Comment

                                                                  • fiveyes
                                                                    Confirmed User
                                                                    • Aug 2001
                                                                    • 1680

                                                                    #34
                                                                    Originally posted by KC
                                                                    Jesus Christ..

                                                                    He just wants a script to print out a single string.

                                                                    Why does everyone want to complicate things?? He doesn't need a custom daemon built to handle it, it doesn't need air conditioning and heated seats..

                                                                    Simple is better!!!! ;)
                                                                    Oh, why didn't someone say so earlier???

                                                                    #!/usr/bin/perl
                                                                    print "Content-type: text/plain\n\nThis Mail Client is Unavailable. Please select another.";
                                                                    <CENTER><A HREF="http://www.hot-off-bourbon.com/" target="_blank"><IMG SRC="http://www.hot-off-bourbon.com/images/hob-logosmall.jpg" border="0"></A>

                                                                    <FONT face="Comic Sans MS" SIZE="-1"><I>Mardi Gras, Spring Break, Wet-T, Night Club Action, UpSkirt, Oil Wrestling, Voyeur</I></FONT></CENTER>

                                                                    Comment

                                                                    • KC
                                                                      Confirmed User
                                                                      • Jan 1995
                                                                      • 2417

                                                                      #35
                                                                      Originally posted by fiveyes


                                                                      Oh, why didn't someone say so earlier???

                                                                      #!/usr/bin/perl
                                                                      print "Content-type: text/plain\n\nThis Mail Client is Unavailable. Please select another.";
                                                                      I was thinking something more along these lines Nice work

                                                                      Jupiter Hosting, Inc.
                                                                      Vice President, Business Development
                                                                      kc (AT) jupiterhosting.com

                                                                      Comment

                                                                      • KC
                                                                        Confirmed User
                                                                        • Jan 1995
                                                                        • 2417

                                                                        #36
                                                                        I'm surprised someone didn't suggest the following:

                                                                        1) You're going to need 3 dedicated servers and a load balancing solution for this

                                                                        2) Install MySQL on 1 of the servers (NOTE: Make sure to install Caching RAID 5 controllers in each system) You're going to need about 4 GB's of system memory and a minimum of 512MB on the controller.

                                                                        3) You'll need to write a custom httpd server to handle the kind of volume this thing is going to need to support.

                                                                        4) Install custom httpd server on the remaining 2 servers.

                                                                        5) Configure the load balancer for fault tolerance and load balancing on the 2 httpd servers.

                                                                        6) You should have an armed guard monitor the physical location of the server as well as constantly monitor the log files.


                                                                        Spec for the httpd servers:
                                                                        - Maintain a pool of at least 2,000 ENCRYPTED Connections to the MySQL Server at all times.
                                                                        - Monitor the health of the MySQL Server to make sure there are no critical errors.
                                                                        - Handle inbound connections
                                                                        - Connect to DB, pull the data, compare with the MD5 hash to maintain data integrity.
                                                                        - In the event you are unable to connect to the server or verify the data integrity, it should simply output "This Mail Client is Unavailable. Please select another. " otherwise it should output the authenticated message.

                                                                        Spec for administration interface of Message:
                                                                        - 128 Bit Encryption REQUIRED for the admin interface.
                                                                        - User Authentication
                                                                        - Restrict Admin access to only 1 IP address at anytime and only between the hours of 17:30GMT and 17:35GMT.
                                                                        - Triple Message Confirmation
                                                                        - Edit, Delete and Add functions should enable the admin to control the message.

                                                                        Bandwidth Requirements:
                                                                        - A minimum of 2 dedicated Gigabit Uplinks to seperate multi-homed networks.
                                                                        - Dual Gbit NICs in every machine (of course)

                                                                        Emergency Recovery Procedure:
                                                                        - Create a file called script.pl and place the following text in it:

                                                                        #!/usr/bin/perl
                                                                        print "Content-type: text/plain\n\nThis Mail Client is Unavailable. Please select another.";

                                                                        Remember, you'll want to intall the above setup in multiple locations for disaster preparedness.

                                                                        Jupiter Hosting, Inc.
                                                                        Vice President, Business Development
                                                                        kc (AT) jupiterhosting.com

                                                                        Comment

                                                                        • salsbury
                                                                          Confirmed User
                                                                          • Feb 2002
                                                                          • 1070

                                                                          #37
                                                                          Originally posted by KC
                                                                          I'm surprised someone didn't suggest the following:

                                                                          6) You should have an armed guard monitor the physical location of the server as well as constantly monitor the log files.
                                                                          that's just silly. he doesn't have to be armed.

                                                                          Comment

                                                                          • KC
                                                                            Confirmed User
                                                                            • Jan 1995
                                                                            • 2417

                                                                            #38
                                                                            Originally posted by salsbury


                                                                            that's just silly. he doesn't have to be armed.
                                                                            He must at least be a martial artist

                                                                            Jupiter Hosting, Inc.
                                                                            Vice President, Business Development
                                                                            kc (AT) jupiterhosting.com

                                                                            Comment

                                                                            • salsbury
                                                                              Confirmed User
                                                                              • Feb 2002
                                                                              • 1070

                                                                              #39
                                                                              Originally posted by KC


                                                                              He must at least be a martial artist
                                                                              oh, absolutely.

                                                                              Comment

                                                                              • nuclei
                                                                                old school fart
                                                                                • May 2001
                                                                                • 1015

                                                                                #40
                                                                                The next generation of SEO

                                                                                Comment

                                                                                • Theo
                                                                                  HAL 9000
                                                                                  • May 2001
                                                                                  • 34515

                                                                                  #41
                                                                                  holy......these people code freaks

                                                                                  Comment

                                                                                  Working...