[HPADM] perl code help

From: Binkley Robert - rbinkl (Robert.Binkley@acxiom.com)
Date: Wed Jan 15 2003 - 21:44:19 EST


> I am working on an program , that is am menu based application, that
> I want to use in the web environment.
> I am not sure on how to get the information to display back
>
>
>
> 1)I code html
>
>
> <HTML><BODY>
> <FORM ACTION="http://sandbox./cgi-bin/test.cgi" NAME=BackupUtility >
>
> <H1>Backup Utilities Operation Menu</H1>
> 1.) BackEx Dashboard Report<BR>
> 2.) Offsite Report<BR>
> 3.) Onsite Report<BR>
> 4.) Enterprise Tape Report<BR>
> 5.) Show Tape Drive Status<BR>
> 6.) Show Library Slots<BR>
> <P>
> Choice <INPUT NAME="COMMAND_OPTION"size=4>
> <P>
> <INPUT TYPE=SUBMIT VALUE="GO!">
>
> </BODY> </HTML>
>
>
>
> Perl Menu"""" this is the code I want executed from the choices above ,
> and the report be displayed back to the screen .
> And once the selection is done go back to the main screen.
>
>
>
>
> #!perl -w
> # Author Robert Binkley
> print "Content-Type:text/html;charset=iso-8859-11310\n\n";
> print "<html>\n";
> print "<head>\n";
> my $Myoutfile = '/tmp/bumenu.out.$$';
> my $MySubject = '';
> my $MyChoice = $cgi->param('layout_number');
>
> #my $mypreview = "screen";
> my $MyChoice = '';
> #my $MyClear = system("cls");
> #my $MyClear = `clear`;
>
> printf "$MyClear";
>
>
> my @MyOperation = ( '',
> "sudo /usr/local/backup/scripts/backexdb",
> "sudo \$SSPRODIR/bin/bexrpt -r jb_offsite",
> "sudo \$SSPRODIR/bin/bexrpt -r onsite",
> "sudo \$SSPRODIR/bin/bexrpt -r all",
> "sudo /usr/local/backup/scripts/showdrivestatus",
> "sudo /usr/local/backup/scripts/showslotstatus"
> );
>
> my @MyTitle = ( '',
> "Bumenu backexdb Report -",
> "Bumenu Offsite Report -",
> "Bumenu Onsite Report -",
> "Bumenu Enterprise Tape Report -",
> "Bumenu Tape Drive Status Report -",
> "Bumenu Library Slot Report -",
> );
>
> my $mail_addr = $ENV{USERNAME};
> my $MyDomain = '@acxiom.com';
>
> while ( 1 ) {
> # screen_menu();
> printf "Choice was %-s\n", $MyChoice;
> last if ( $MyChoice ==8 );
> if ( $MyChoice != 7 ) {
> work_to_do()
> }else {
> if ( $mypreview eq 'screen' ) {
> proc_email();
> }else {
> $mypreview = 'screen';
> }
> }
> }
>
> #
> ##
> ### Start of Subs
> ##
> #
>
> sub screen_menu {
> while ( 1 ) {
> printf "\n"x6;
> printf "\t\t\tBackup Utilities Operation Menu\n";
> printf "\n"x3;
> printf "\t 1.)\t BackEx Dashboard Report\n";
> printf "\t 2.)\t Offsite Report\n";
> printf "\t 3.)\t Onsite Report\n";
> printf "\t 4.)\t Enterprise Tape Report\n";
> printf "\t 5.)\t Show Tape Drive Status\n";
> printf "\t 6.)\t Show Library Slots\n";
>
> if ( $mypreview eq "screen" ) {
> printf "\t 7.)\t Toggle Output to Mail - \n\t\t\tCurrent
> setting is to send output to Screen\n";
> }else {
> printf "\t 7.)\t Toggle Output to Screen - \n\t\t\tCurrent
> setting is to mail output to $mail_addr\@acxiom.com\n"
> }
> printf "\t 8.)\t quit\n";
> printf "\n"x2;
> printf "\tEnter Command Number and press Enter: ";
> chomp($MyChoice = <STDIN>);
>
> if ( $MyChoice !~ /^\s*[1-8]\s*/ ) {
> printf "Only 1 thru 8 was expected and you entered:
> <$MyChoice>\n";
> next;
> }
> last;
> }
> } # end screen_menu
>
> sub work_to_do {
> # my $MyOutput = `$MyOperation[$MyChoice] > $Myoutfile`;
> my $MyOutput = sprintf "%-s > $Myoutfile", $MyOperation[$MyChoice];
> $MySubject = $MyTitle[$MyChoice];
> #
> # Need to do a more for the output here
> #
> printf "ac:%-s\nti:%-s\n", $MyOutput, $MySubject;
> }
>
> sub proc_email {
> my $MyBackEmailId = $mail_addr;
> OUTER1: while ( 1 ) {
> printf "\tThe report will be sent via email to $mail_addr%-s, OK
> [Y/N]: ", $MyDomain;
> chomp(my $MyAns = <STDIN>);
> last if ( $MyAns =~ /\s*y\s*/i );
> OUTER2: while ( 1 ) {
> printf "\n";
> printf "\tEnter the ID to send the email to:\n (Don't add the
> %-s): ", $MyDomain;
> chomp(my $MyAns2 = <STDIN>);
> if ( $MyAns2 =~ /\@/ ) {
> printf "You were not supposed to have the \@ and you
> entered:\n<%-s>\n", $MyAns2;
> printf "Please retry.\n";
> next OUTER2;
> }
> OUTER3: while ( 1 ) {
> printf "Using %-s%-s for email. OK [Y/N]: ", $MyDomain;
> chomp(my $MyAns3 = <STDIN>);
> last if ( $MyAns3 =~ /^\s*y\s*$/i );
> $mail_addr = $MyBackEmailId;
> next OUTER1;
> } # end of OUTER3
> } # end of OUTER2
> } # end of OUTER1
>
> } # end of proc_email
>
> #
> ##
> ### End of Subs
> ##
> print "</body></html>\n";
>
> #
>
>
>
>
>
>
>

**********************************************************************
The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged.
If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination,
distribution, or copying of this communication is strictly
prohibited.
If you have received this communication in error,
please re-send this communication to the sender and
delete the original message or any copy of it from your
computer system. Thank You.

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:24 EDT