Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^4: INSERT file contents inside a table

by theravadamonk (Scribe)
on Jun 06, 2018 at 11:04 UTC ( [id://1216015]=note: print w/replies, xml ) Need Help??


in reply to Re^3: INSERT file contents inside a table
in thread INSERT file contents inside a table

Hi Poj,

Sorry for disturbing u. May I ask another question?

I want to release the quarantined mail right there. I Just want to add a link to release the quarantined mail. If u have a better way, You may suggest.

I just added below stuffs to the code. But It does NOT work.

<td><a href=/cgi-bin/release.pl>$id</a></td>

This release.pl works separately. But with the link I added, It does NOT work. Below is the way to release it.

#system("sudo /usr/bin/amavisd-release spam-KvefDigP-2QR.gz system("sudo /usr/bin/amavisd-release $id

I think this below code has a mistake somewhere. IF I can get it solved it's the easiest way. Anyway, If I click the link, It SHOULD ask an question "Are You sure to release it with YES and NO option?

<td><a href=/cgi-bin/release.pl>$id</a></td>

Your Ideas r welcome to solve it.

Replies are listed 'Best First'.
Re^5: INSERT file contents inside a table
by poj (Abbot) on Jun 06, 2018 at 14:24 UTC
    release.pl works separately.

    Show the release.pl code that works

    I just added below stuffs to the code.But It does NOT work.

    What is the error shown in the web server log ?

    poj

      Hi, thnaks for your reply. I am doing it with a front end html code.

      Here's my front end html code. it's release.html

      <html> <head> <title>Release your email</title> </head> <body bgcolor="#95B8DB" onload="parent.adjustMyFrameHeight();"> <form action="/cgi-bin/release.pl" method="post"> <h1>Release your email</h1> <div style="height:500px; dispaly:block;">Pls input the Mail ID: <inpu +t name="release" size="20" style="height:30px"> <input type="submit" +value="Release" style="height:30px"></div> </form> </body> </html>

      Here's the release.pl code. It works. Remember I still am a Novice. Pls don't blame my perl code. I don't feel shy. Everyone learns little by little. any way, This code works.

      #!/usr/bin/perl use CGI qw(:standard); $ENV{"PATH"} = "/usr/sbin:/usr/bin:/sbin:/bin"; $release = param('release') || '<i>(No input)</i>'; print "Content-type: text/html\n\n"; print "<body bgcolor=\"#95B8DB\">"; print "<h1>You are releasing: $release</h1>"; system("/bin/echo > /tmp/releaseme"); system("sudo /bin/chmod 777 /tmp/releaseme"); system("sudo /usr/bin/amavisd-release $release 2> /tmp/releaseme"); if (system("less /tmp/releaseme |grep Ok > /dev/null") == 0) { print "<h2>Your Mail ID $release was released.\n</h2>"; print "<br />"; } else { print "<h2>Error!!! Wrong Mail ID, Pls Input the Right Mail ID +.\n</h2>"; print "<br />"; } print "</body>";

      Anyway, I had to change the code since it gave an error due to below line in that release.pl code

      $release = param('release') || '<i>(No input)</i>';

      I changed it in this way. Pls see the below release.pl code. THIS IS the code I now use. But does NOT work

      #!/usr/bin/perl use CGI qw(:standard); $ENV{"PATH"} = "/usr/sbin:/usr/bin:/sbin:/bin"; #$release = param('release') || '<i>(No input)</i>'; print "Content-type: text/html\n\n"; print "<body bgcolor=\"#95B8DB\">"; #print "<h1>You are releasing: $release</h1>"; print "<h1>You are releasing: $id</h1>"; system("/bin/echo > /tmp/releaseme"); system("sudo /bin/chmod 777 /tmp/releaseme"); system("sudo /usr/bin/amavisd-release $id 2> /tmp/releaseme"); if (system("less /tmp/releaseme |grep Ok > /dev/null") == 0) { print "<h2>Your Mail ID $id was released.\n</h2>"; print "<br />"; } else { print "<h2>Error!!! Wrong Mail ID, Pls Input the Right Mail ID +.\n</h2>"; print "<br />"; } print "</body>";

      Many thanks for your reply. Your INPUTS r welcome. Thanks a lot

        Try this and post the result. Be aware of the security risk of user provided data, see Calling External Commands More Safely for better solutions.

        #!/usr/bin/perl use strict; use CGI qw(:standard); use CGI::Carp 'fatalsToBrowser' ; # only for test my $id = param('release'); my $cmd = "sudo /usr/bin/amavisd-release $id 2"; my $result; if ($id =~ /^spam-[a-zA-Z0-9-]+\.gz$/) { $result = qx/ $cmd /; } else { $result = "ERROR : Invalid id '$id'"; } print "Content-type: text/plain\n\n"; print "$cmd\n\n$result";
        poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1216015]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 13:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found