Using Netscape browser when an invalid number in entered in the textbox, the program is returning the html instructions instead of the webpage with an error message. Using Internet Explorer the program works fine. Please tell me why this is happening and how I can fix it.

Program:

use cgi_utils; use Navigation_bar; use Sspec; use CGI qw(:all); use Far; use cgi_tables; use Fdi_display_file; use Odi_keyed_file; use cgi_site_params; use Farrsh; #use strict; my $total_file_count = 0; my $image_file_count = 0; my @all_files = (); my @image_files = (); my $total_size = 0; my $image_size = 0; my $redir; my $progname = "estimate_edtup_size.cgi"; my $lbxnum; my @lbxnum; my $query = new CGI; my $podid; my @all_dirs; my $all_dirs; my $outfile; my $event; my $asterisk = "*"; my $aspec; my $this_dir; my $env = &get_environment; my $dirname = "/usr/$env/data/editspecs/acct"; my $date; my $sspec = new Sspec; my @datadir; my $siteCode = $sspec->get_site; my $host = get_host; my $domain = get_domain; my $runhost = "ipm0"; my $bpath = "html/custom"; my $nav = new Navigation_bar; $nav->add ( gif => "Main_Menu.gif", href => path_to_script ("main_menu.cgi",$host), desc => "Return to Main Menu"); if(param('redir_to_host')) {&redir_to_host;} if (defined($lbxnum=param('lbxnum'))) { &header1; &getfiles; &footer; } if (!defined($lbxnum=param('lbxnum'))) { &header1; &initask; &footer; } ########################################################## sub header1 { print header, + start_html('-title'=> 'Edtup Size Estimate'), $nav->display, br; print center (h2("Edtup Size Estimate")); br; } ######################################################### sub header2{ br; print center (h3("Size Estimate Results")); } ########################################################### sub footer { print br,hr,"\n", center(a({'-href'=>"http://$runhost.$domain/usr/$env/$bpath/cus +tom_menu.cgi", '-onmouseover'=>"self.status='Return to Custom Menu'; re +turn true;"}, "Return to Custom Menu"), "|", a ({'-href'=>"http://$runhost.$domain/usr/$env/$bpath/$prog +name", '-onmouseover'=>"self.status='Return to Edtup Size Estim +ate'; return true;"}, "Edtup Size Estimate"),"\n"); } ########################################################## sub initask { print center(start_form('-method'=>"POST",'-action'=>"http://$host. +$domain/usr/$env/$bpath/$progname"), "Enter a valid lockbox number:", "\n", textfield('-name'=>"lbxnum",'-size'=>6, '-maxlength'=>6), "\n", br, br, hidden('-name'=>"redir_to_host", '-value'=>"redir_to_host"), "\n", submit('-value'=>"Get Files", '-name'=>"Submit"), "\n", end_form, "\n"); } ########################################################## sub getfiles { $lbxnum = param('lbxnum'); unless($lbxnum=~/\d{6}/) { print center (h2("An error occurred, the lockbox number $lbxnum is +invalid")); return; } @all_dirs = glob("/usr/$env/data/lb/$lbxnum/rd/????????/outputs/w?"); my $no_webs = @all_dirs; if ($no_webs == "0") { print center (h2("Verify Lockbox number $lbxnum, there are no Image T +ransmissions or Lockbox number does not exist")); return; } $outfile = "$lbxnum.csv"; open (OUT, ">/usr/$env/log/$outfile"); # || die "Couldn't open output + file $outfile"; print OUT "Lockbox,Date,Event,Image Files,Total Files,Image Size in M +B, Total Size in MB\n"; foreach my $this_dir (@all_dirs) { + my ($date, $event) = (split(/\//,$this_dir))[7,9]; $total_file_count = 0; $image_file_count = 0; @all_files = (); @image_files = (); $total_size = 0; $image_size = 0; read_dir_recursive($this_dir); # Convert from bytes to MB $image_size /= 1048576; $total_size /= 1048576; print "Lbx=$lbxnum....Date=$date....Event=$event....Image_Files=$image +_file_count....Total_Files=$total_file_count....Image_Size in MB=$image_size....Total_Size in MB=$total_size\n", br,br; #print OUT "Lbx=$lbxnum,Date=$date,Event=$event,Image_Files=$image_fil +e_count,Total_Files=$total_file_count,Image_Size in MB=$im age_size,Total_Size in MB=$total_size\n"; } close(OUT); } ############################################################# sub redir_to_host { $lbxnum = param ('lbxnum'); if ($lbxnum=~/\d{6}/) #change to check for 6 digits { $aspec = new Odi_file ("$dirname", "$siteCode-$lbxnum"); unless ($aspec->{read_successfully}) { print center (h2("the lockbox number $lbxnum does not exist")); return; } $podid = $aspec->{info}{"PodID"}; } else { print center (h2("the lockbox number $lbxnum is invalid")); return; } $redir = "http://oos0$podid.$domain/usr/$env/$bpath/$progname?getfile +s=g&lbxnum=$lbxnum"; print CGI->redirect(-uri=>$redir); } ################################################################### # Sub to read a directory recursively and update variables ################################################################## sub read_dir_recursive { my $dir = shift; opendir( WEBDIR, $dir); my @files = grep !/^\.\.?$/, readdir(WEBDIR); closedir(WEBDIR); foreach (@files) { next if (-l "$dir/$_"); if (-f "$dir/$_") { my $size = (stat("$dir/$_"))[7]; #print "Web Files $_ $size",br; push(@all_files, "$dir/$_"); $total_file_count++; $total_size += $size; if (/jpg$|gif$/) { $image_file_count++; push(@image_files, "$dir/$_"); $image_size += $size; } } if (-d "$dir/$_") { read_dir_recursive("$dir/$_"); } } }

Edit by tye to add CODE and READMORE tags


In reply to Netscape returns script source on error, IE works by Ursula

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.