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

Re: [PBML] CGI script that will SENDMAIL when file added to folder.

Expand Messages
  • guest user <docdoo99@yahoo.com>
    ... Because I am not allowed to edit the current upload CGI (from client). ... I ve already had something similar: ##part1 Send the new upload entry as email
    Message 1 of 8 , Jan 2, 2003
    • 0 Attachment
      > Why use a CGI script? There's nothing interfacing
      > with the web. It sounds more like a utility or
      > administrative script.

      Because I am not allowed to edit the current upload CGI (from
      client).

      > It should be possible to send an email from the
      > current upload script. This would allow you to send any
      > of the common server variables including IP and the
      > file name. I haven't done this much but:
      >
      > open MAIL, "|$sendmail $email" or
      > die "can't open sendmail: $email: $!";
      >
      > should open sendmail assuming the path is in
      > $sendmail, a valid email address is in $email, and
      > your using a *nix flavored OS. Continue with
      > something like:
      >
      > print MAIL "To: $email\n";
      > print MAIL "From: $server\n";
      > print MAIL "Subject: New file uploaded\n";
      > print MAIL "message";
      >
      > close MAIL;

      I've already had something similar:
      ##part1 Send the new upload entry as email to recipient
      $notification = "yes";
      $mailprog = "/usr/sbin/sendmail"; # path to sendmail
      $recipient = "email\@..."; # your email address
      ##
      =================
      ##part2
      sub send_mail {
      open (MAIL, "|$mailprog -t");
      print MAIL "To: $recipient\n";
      print MAIL "Subject: File uploaded!\n";
      print MAIL "Reply-to: $FORM{'email'}\n";
      print MAIL "There is a new upload at docdoo.com:\n\n";
      print MAIL "$FORM{'message'}\n";
      print MAIL "$this_day";
      close (MAIL);
      }
      ####

      But like I said, I can only add a script in the upload target
      directory. This is why I thought a basic (hehe) script that
      uses "sendmail" to email me when file is added to specified
      directory. This way nothing effects their current setup.
    • Octavian Rasnita
      Make a CGI script which is executed by cron or which is executed each time someone will visit a certain web page from that site. Put it to create a list of
      Message 2 of 8 , Jan 2, 2003
      • 0 Attachment
        Make a CGI script which is executed by cron or which is executed each time
        someone will visit a certain web page from that site.
        Put it to create a list of files from that directory, and each time is
        executed, let it compare it with the list of the files from that
        directory...

        Teddy,
        Teddy's Center: http://teddy.fcc.ro/
        Email: orasnita@...

        ----- Original Message -----
        From: <docdoo99@...>
        To: <perl-beginner@yahoogroups.com>
        Sent: Thursday, January 02, 2003 11:43 PM
        Subject: Re: [PBML] CGI script that will SENDMAIL when file added to folder.


        > Why use a CGI script? There's nothing interfacing
        > with the web. It sounds more like a utility or
        > administrative script.

        Because I am not allowed to edit the current upload CGI (from
        client).

        > It should be possible to send an email from the
        > current upload script. This would allow you to send any
        > of the common server variables including IP and the
        > file name. I haven't done this much but:
        >
        > open MAIL, "|$sendmail $email" or
        > die "can't open sendmail: $email: $!";
        >
        > should open sendmail assuming the path is in
        > $sendmail, a valid email address is in $email, and
        > your using a *nix flavored OS. Continue with
        > something like:
        >
        > print MAIL "To: $email\n";
        > print MAIL "From: $server\n";
        > print MAIL "Subject: New file uploaded\n";
        > print MAIL "message";
        >
        > close MAIL;

        I've already had something similar:
        ##part1 Send the new upload entry as email to recipient
        $notification = "yes";
        $mailprog = "/usr/sbin/sendmail"; # path to sendmail
        $recipient = "email\@..."; # your email address
        ##
        =================
        ##part2
        sub send_mail {
        open (MAIL, "|$mailprog -t");
        print MAIL "To: $recipient\n";
        print MAIL "Subject: File uploaded!\n";
        print MAIL "Reply-to: $FORM{'email'}\n";
        print MAIL "There is a new upload at docdoo.com:\n\n";
        print MAIL "$FORM{'message'}\n";
        print MAIL "$this_day";
        close (MAIL);
        }
        ####

        But like I said, I can only add a script in the upload target
        directory. This is why I thought a basic (hehe) script that
        uses "sendmail" to email me when file is added to specified
        directory. This way nothing effects their current setup.



        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/
      • guest user <docdoo99@yahoo.com>
        ... each time ... time is ... This would create exessive CPU usage on the server. Especially since there are 100 s of other files to compare against (many
        Message 3 of 8 , Jan 3, 2003
        • 0 Attachment
          --- In perl-beginner@yahoogroups.com, "Octavian Rasnita"
          <orasnita@h...> wrote:
          > Make a CGI script which is executed by cron or which is executed
          each time
          > someone will visit a certain web page from that site.
          > Put it to create a list of files from that directory, and each
          time is
          > executed, let it compare it with the list of the files from that
          > directory...
          -----

          This would create exessive CPU usage on the server. Especially since
          there are 100's of other files to compare against (many large). Its
          kind of like using a drill press to punch a hole in paper :) But
          your right, it can be made to work... In the past, I've only used
          cron to send me logs (error & access) every 3:am.

          There must be a cleaner (simpler) way of doing this. Maybe its time
          to re-code the whole entire thing from scratch :-O
        • Charles K. Clarkson
          ... I can think of two paths. Write a script that compares an old directory listing with a current directory listing and reports changes. Then cronjob the
          Message 4 of 8 , Jan 3, 2003
          • 0 Attachment
            guest user <docdoo99@...> replied:

            : This is why I thought a basic (hehe) script that
            : uses "sendmail" to email me when file is added to
            : specified directory. This way nothing effects
            : their current setup.

            I can think of two paths. Write a script that
            compares an old directory listing with a current
            directory listing and reports changes. Then
            cronjob the script (I'm assuming your using unix).
            I don't see how you'd get a user IP or the
            original file name but you would have the new
            filename.

            The second idea would be to use signal
            processing to alert a perl program that a new
            file has been uploaded. I have no idea how to do
            this. Perhaps a kind unix person from the list can
            tell us if it is possible to use signals in this
            way. This approach would be very OS specific.

            Either of these two approaches does not
            involve programming the CGI. There is no need to
            communicate with a browser to send email via
            send mail.

            (A third approach would be to rewrite the
            script you're "not allowed" to rewrite. Of
            course this depends on why you're not allowed
            to edit it. Think of it as Civil Disobedience,
            but don't lose the job over it.)



            HTH,

            Charles K. Clarkson
            --
            Head Bottle Washer,
            Clarkson Energy Homes, Inc.
            Mobile Home Specialists
            254 968-8328
          • Octavian Rasnita
            No, it s not a big job if there are only 100 files. You don t need to compare the content of the files but only their names. You just need to compare an array
            Message 5 of 8 , Jan 3, 2003
            • 0 Attachment
              No, it's not a big job if there are only 100 files.
              You don't need to compare the content of the files but only their names.

              You just need to compare an array with 100 file names taken from a text file
              that keeps the old file names with the current list of file names taken from
              that directory.
              But it would be much more simple just to add a few lines of code to the
              script used for uploading.


              Teddy,
              Teddy's Center: http://teddy.fcc.ro/
              Email: orasnita@...

              ----- Original Message -----
              From: <docdoo99@...>
              To: <perl-beginner@yahoogroups.com>
              Sent: Friday, January 03, 2003 4:29 PM
              Subject: Re: [PBML] CGI script that will SENDMAIL when file added to folder.


              --- In perl-beginner@yahoogroups.com, "Octavian Rasnita"
              <orasnita@h...> wrote:
              > Make a CGI script which is executed by cron or which is executed
              each time
              > someone will visit a certain web page from that site.
              > Put it to create a list of files from that directory, and each
              time is
              > executed, let it compare it with the list of the files from that
              > directory...
              -----

              This would create exessive CPU usage on the server. Especially since
              there are 100's of other files to compare against (many large). Its
              kind of like using a drill press to punch a hole in paper :) But
              your right, it can be made to work... In the past, I've only used
              cron to send me logs (error & access) every 3:am.

              There must be a cleaner (simpler) way of doing this. Maybe its time
              to re-code the whole entire thing from scratch :-O





              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/
            • guest user <docdoo99@yahoo.com>
              ... =========== They don t want it changed because the way it stands now...it ain t broke :) But to be quite honest with you, this automated sendmail script
              Message 6 of 8 , Jan 3, 2003
              • 0 Attachment
                >A third approach would be to rewrite the script you're "not
                >allowed" to rewrite. Of course this depends on why you're not
                >allowed to edit it. Think of it as Civil Disobedience, but don't
                >lose the job over it.

                ===========

                They don't want it changed because the way it stands now...it ain't
                broke :)

                But to be quite honest with you, this automated "sendmail" script is
                to speed up the work that I need to do. It my gain, not theirs. I
                could sneak the code into the original, but that is not my style :-)

                my $COMMENT = 'my search continues'; # Sigh
              Your message has been successfully submitted and would be delivered to recipients shortly.