The script modifies several devices and would like the progress of each device printed when they are completed. The code resides on a SUN OS server using tomcat. The browsers tried are Netscape 9.0 and IE 7.0. The output of the script is not displayed until it completes. Here is the code:
#!/usr/bin/perl use CGI qw(:standard); $bbslist = "/opt/BBSacct/bbslist.txt"; $bbs = "/opt/BBSacct/bbsacct.exe"; @bbspop = ("ALL"); $BBSPass = "!BBS4acct"; $| = 1; open(BBSL,$bbslist); @lines = <BBSL>; close(BBSL); foreach $line (@lines) { chomp($line); @s = split(/ /,$line); push(@bbspop,$s[0]); } print header; print "<FONT color=#006600><h1>BBS User Account Management</h1></FONT> +\n"; print start_html('BBS Account Management'), start_form, "User Name: ",textfield(-name=>'Uname',-size=>15), p, radio_group(-name=>'ad',-values=>['Add Account','Delete Account',' +Change Password'],-default=>'Add Account'), p, "BBS Hostname: ",popup_menu(-name=>'Host',-values=>[@bbspop],-defa +ult=>'ALL'), p, "New Password: ",textfield(-name=>'Npass',-size=>15)," (Minimum 8 +characters containing 1 upper, 1 lower, 1 number, and 1 special)", p, "Execute Password: ",password_field(-name=>'Epass',-size=>8)," ",s +ubmit(-name=>'Execute'), end_form, hr; if (param()) { $Epass = param(Epass); $Uname = param(Uname); $ad = param(ad); $Host = param(Host); $Npass = param(Npass); if ($Epass ne BBS) { print "<FONT color=red><TT><B>Invalid Execute Password</B></TT +></FONT>\n"; exit; } else { print "<TT><B>Processing</B></TT>\n"; print "<CENTER></CENTER>\n"; } stringcheck($Uname,"User Name"); if ($Host ne "ALL") { $pc = `ping $Host`; if ($pc =~ /alive/) { } else { print "<FONT color=red><TT><B>Could not connect to $Host</ +B></TT></FONT>\n"; print "<CENTER></CENTER>\n"; exit; } open(BBSF,$bbslist); @lines = <BBSF>; close(BBSF); foreach $line (@lines) { chomp($line); @s = split(/ /,$line); $hc = $s[0]; if ($Host =~ /$hc/) { $Pass = $s[1]; } } if ($ad eq "Add Account") { stringcheck($Npass,"New Password"); runexp($Host,$Pass,$Uname,$Npass,"a"); } if ($ad eq "Delete Account") { runexp($Host,$Pass,$Uname,$Npass,"d"); } if ($ad eq "Change Password") { stringcheck($Npass,"New Password"); runexp($Host,$Pass,$Uname,$Npass,"d"); runexp($Host,$Pass,$Uname,$Npass,"a"); } } else { open(BBSL,$bbslist); @lines = <BBSL>; close(BBSL); foreach $line (@lines) { chomp($line); @s = split(/ /,$line); $Host = $s[0]; $Pass = $s[1]; $pc = `ping $Host`; if ($pc =~ /alive/) { } else { print "<FONT color=red><TT><B>Could not connect to $Ho +st</B></TT></FONT>\n"; print "<CENTER></CENTER>\n"; next; } if ($ad eq "Add Account") { stringcheck($Npass,"New Password"); runexp($Host,$Pass,$Uname,$Npass,"a"); } if ($ad eq "Delete Account") { runexp($Host,$Pass,$Uname,$Npass,"d"); } if ($ad eq "Change Password") { stringcheck($Npass,"New Password"); runexp($Host,$Pass,$Uname,$Npass,"d"); runexp($Host,$Pass,$Uname,$Npass,"a"); } } } } sub stringcheck { my($nc,$em) = @_; if (length($nc) == 0) { print "<FONT color=red><TT><B>ERROR - Must input $em</B></TT>< +/FONT>\n"; exit; } } sub runexp { my($Ho,$Pa,$Us,$Na,$Wh) = @_; @f = `$bbs $Ho $Pa $Us $Wh $Na`; foreach $line (@f) { chomp($line); if ($line =~ /COMPLETE/) { @s = split(/Z/,$line); $em = $s[1]; print "<FONT color=green><TT><B>$em Complete</B></TT></FON +T>\n"; print "<CENTER></CENTER>\n"; } if ($line =~ /^ERROR/) { @s = split(/Z/,$line); $em = $s[1]; print "<FONT color=red><TT><B>$em</B></TT></FONT>\n"; print "<CENTER></CENTER>\n"; } } }

In reply to Re^2: unbuffer output by bluedragon2
in thread unbuffer output by bluedragon2

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.