Changeset 14512 for misc/runpugs

Show
Ignore:
Timestamp:
10/24/06 18:30:58 (2 years ago)
Author:
andara
Message:

[runpugs]
-now runs latest release by default, latest devel as option
-runpugs2: devel version, now with non-interactive sessions (not live yet)

Location:
misc/runpugs
Files:
14 modified

Legend:

Unmodified
Added
Removed
  • misc/runpugs/bin/termdispatcher.pl

    r14225 r14512  
    1515print "Sending msg $id: $cmd\n"; 
    1616my $ip="127.0.0.1"; 
    17 my $reply = &WebTerminal::Dispatcher::send($id,$ip,$prompt.$cmd); 
     17my $dev=1; 
     18my $reply = &WebTerminal::Dispatcher::send($id,$ip,$dev,$prompt.$cmd); 
    1819print $reply; 
    1920 
  • misc/runpugs/bin/termdispatcher2.pl

    r14449 r14512  
    1212 
    1313my $id=$ARGV[0]||-1; 
    14 my $cmd=$ARGV[1] || 'my $a='.$id.';say "Hello, $a";'; 
     14my $cmd=$ARGV[1] || 'print "hello\n";say "there";print 4'; 
     15#my $cmd=$ARGV[1] || 'my $a='.$id.';'."\n".'say "Hello, $a";'."\n".'print 1;'; 
     16#my $cmd=$ARGV[1] || 'my $a='.$id.';'.'say "Hello, $a";'.'print 1;'; 
    1517#my $cmd='my $a='.$id.';say "Hello, $a";'; 
    1618#my $prompt='pugs> '; 
    17 my $prompt='Prelude> '; 
     19#my $prompt='Prelude> '; 
    1820print "Sending msg $id: $cmd\n"; 
    1921my $ip="127.0.0.1"; 
    20 (my $reply,my $prompt,my $histref) = &Web::Terminal::Dispatcher::send($id,$ip,$prompt.$cmd); 
     22(my $reply,my $prompt,my $histref) = 
     23&Web::Terminal::Dispatcher::send($id,$ip,0,0,$cmd); 
    2124print $reply; 
    2225print "\nHistory\n"; 
  • misc/runpugs/cgi-bin/runpugs

    r14430 r14512  
    9696    my $reply='pugs> '; 
    9797    my $testing=$query->param('testing')||1; 
     98    my $dev=$query->param('reldev')||0; 
     99    $dev=$dev*1; 
    98100    if (not $testing) { 
    99101    $reply = "Sorry, runpugs is not available at the moment."; 
     
    113115        $cmd=~s/$1/:q/; 
    114116    }  
    115     $reply = &WebTerminal::Dispatcher::send($sessionid,$ip,$cmd); 
     117    $reply = &WebTerminal::Dispatcher::send($sessionid,$ip,$dev,$cmd); 
    116118    $reply="\n".$reply; 
    117119    } 
    118120    } 
    119121    #$reply.="\n$ip\n$sessionid\n"; 
     122    my $devc=''; 
     123    my $relc='checked'; 
     124    if($dev==1) { 
     125        $devc='checked'; 
     126        $relc=''; 
     127    } 
    120128    my $html=''; 
    121129    open(HTML,"<../data/runpugs.html"); 
    122130    while(<HTML>) { 
    123131    s/_TESTING_/$testing/; 
     132    s/_DEV_/$devc/; 
     133    s/_REL_/$relc/; 
    124134        /input.*name=\"sessionid\"/ && do {$html.='<input type="hidden" name="sessionid" value="'.$sessionid.'">'."\n";next }; 
    125135        /(pugs\&gt\;\&nbsp\;)/ && do {$html.=$cmd.$reply;next}; 
  • misc/runpugs/cgi-bin/runpugs2

    r14449 r14512  
    9696    my $sessionid=shift; 
    9797    my $ip=shift; 
    98 #    my $prompt=$Web::Terminal::Settings::prompt; 
     98    my $dev=$query->param('reldev')||0; 
     99    $dev=$dev*1; 
     100    my $devc=''; 
     101    my $relc='checked'; 
     102    if($dev==1) { 
     103        $devc='checked'; 
     104        $relc=''; 
     105        } 
     106    my $ia=$query->param('ia')||0; 
     107    my $interactive=$ia*1; 
     108    my $html=''; 
     109    if ($interactive==1) { 
     110    my $clear=0; 
    99111    my $nprompt=$query->param('prompt')||$prompt; 
    100112    my $preply=''; 
     
    105117    my @history=(); 
    106118    my $prevcmd=''; 
    107     my $testing=$query->param('testing')||1; 
    108     if (not $testing) { 
     119    my $testing=0; 
     120    if ($testing==1) { 
    109121        $reply = "Sorry, runpugs is not available at the moment."; 
    110122    } else { 
     
    117129        } 
    118130        if ($cmd=~/clear/) { 
     131        $clear=1; 
    119132            $cmd=''; 
    120133            $preply=''; 
     
    128141                $cmd=~s/$1/:q/; 
    129142            }  
    130             ($reply, $nprompt, my $histref) = &Web::Terminal::Dispatcher::send($sessionid,$ip,$cmd); 
     143            ($reply, $nprompt, my $histref) = &Web::Terminal::Dispatcher::send($sessionid,$ip,$dev,$interactive,$cmd); 
    131144            if (defined $histref) { 
    132145                @history=@{$histref}; 
     
    146159    my $replyw="$preply$prompt$prevcmd\n$reply"; 
    147160#            $prompt=$nprompt; 
    148     if($preply eq '' and $cmd eq '') { 
     161    if($clear==1) { 
    149162        $replyw=''; 
    150163    } 
     
    155168    my $historylist="\n"; 
    156169    for my $entry (@history) { 
    157         $entry=~s/\>/\&gt\;/g; 
    158         $historylist.='<option value="'.$entry.'">'.$entry.'</option>'."\n"; 
    159     } 
    160     my $html=''; 
     170        my $entryw=HTML::Entities::encode_entities($entry); 
     171        $historylist.='<option value="'.$entryw.'">'.$entryw.'</option>'."\n"; 
     172    } 
    161173    open(HTML,"<../data/runpugs2.html"); 
    162174    while(<HTML>) { 
     
    165177            next; 
    166178        }; 
    167         s/_TESTING_/$testing/; 
     179        s/_DEV_/$devc/; 
     180        s/_REL_/$relc/; 
    168181        /input.*name=\"sessionid\"/ && do { 
    169182            $html.='<input type="hidden" name="sessionid" value="'.$sessionid.'">'."\n"; 
     
    204217    } 
    205218        close HTML; 
     219 
     220    } else { #not-interactive 
     221    my $script=$query->param('script')||''; 
     222            (my $reply,my $nprompt, my $histref) = 
     223            &Web::Terminal::Dispatcher::send($sessionid,$ip,$dev,$interactive,$script); 
     224   my $nrows=scalar split("\n",$reply);  
     225#    $nrows++; 
     226     ($reply=~/^\s*$/) && ($nrows=1); 
     227    if ($nrows>20) {$nrows=20;} 
     228    open(HTML,"<../data/runpugs2s.html"); 
     229    while(<HTML>) { 
     230        s/_DEV_/$devc/; 
     231        s/_REL_/$relc/; 
     232        s/_NROWS_/$nrows/; 
     233        /_REPLYW_/ && do { 
     234            chomp $html; 
     235            $html.=$reply; 
     236            next; 
     237        }; 
     238        /_SCRIPT_/ && do { 
     239            chomp $html; 
     240            $html.=$script; 
     241            next; 
     242        }; 
     243        /([^\`\\]+$)/ && do {$html.=$1}; 
     244    } 
     245    close HTML; 
     246    } 
    206247        &printhttpheader(); 
    207248        print $html; 
     
    211252################### PRINTHTTPHEADER ####################### 
    212253sub printhttpheader { 
    213 #   my $cookie; 
    214254     unless ($headerprinted) { 
    215  
    216 #     if ($sessionid) { 
    217 #         $cookie = $query->cookie( -name    => 'sessionid', 
    218 #                           -"value" => $sessionid, 
    219 #                           -path    => '/' ); 
    220 #       } 
    221  
    222 $headerprinted=1; 
    223  
    224 #        if ($sessionid) { 
    225 #         print $query->header(-pragma=>'no-cache', 
    226 #                      -cookie=>$cookie, 
    227 #                      -charset=>$lang_charset, 
    228 #                            ); 
    229 #       } else { 
     255        $headerprinted=1; 
    230256         print $query->header(-pragma=>'no-cache', 
    231257                      -charset=>$lang_charset, 
    232258                              ); 
    233 #       } 
    234259   } 
    235260   } 
  • misc/runpugs/data/runpugs.html

    r14380 r14512  
    2727<div id="mainwindow"> 
    2828<h1>Run Perl 6 now -- in your browser!</h1> 
    29 <p>This live web terminal runs the latest development snapshot of 
    30 the <a href="http://www.pugscode.org">pugs</a> interpreter for <a 
     29<p>This live web terminal runs the <a href="http://www.pugscode.org">pugs</a> interpreter for <a 
    3130href="http://dev.perl.org/perl 6/">Perl 6</a>. For more details, read the <a 
    3231href="http://feather.perl6.nl/~andara/runpugs/">info page</a>. 
    3332</p> 
    34 <form style="text-align: center" id="term" name="terminal" action="/cgi-bin/runpugs" method="POST">                   
     33<p>By default, the Pugs session will use the <a 
     34href="http://search.cpan.org/search?query=perl6%3A%3Apugs&mode=module">latest 
     35release</a>. To use the latest development snapshot, change the setting 
     36below.</p> 
     37 
     38<form id="term" name="terminal" action="/cgi-bin/runpugs" method="POST">                   
    3539                                
    3640<input type="hidden" name="testing" value="_TESTING_"> 
    3741<input type="hidden" name="sessionid" value=""> 
    3842<input type="hidden"    name="action" value="runpugs"> 
     43<!--<fieldset>--> 
     44<input type="radio" id="rel" value="0" name="reldev" _REL_ ><label 
     45for="rel">Release</label>&nbsp;&nbsp; 
     46<input type="radio" id="dev" value="1" name="reldev" _DEV_ ><label for="dev">Development</label> 
     47<!--</fieldset>--> 
     48<h2>Interactive Pugs Session</h2> 
    3949<!--<textarea id="history" name="history"  rows="1" cols="1" 
    4050style="overflow: hidden; border: 0px; width: 0px; 
    4151font-size:0px">_CMD_</textarea>--> 
    42 <label for="cmd">Interactive Pugs Session<br> 
     52<!--<label for="cmd">Interactive Pugs Session<br>--> 
    4353<textarea id="cmd" name="cmd" rows="24" cols="80" wrap="virtual" onKeyPress="return submitenter(this,event)"> 
    4454pugs&gt;&nbsp; 
    4555</textarea> 
    46 </label> 
     56<!--</label>--> 
    4757<br> 
    4858<input id="enter" type="submit" value="Submit">&nbsp;&nbsp;&nbsp; 
  • misc/runpugs/data/runpugs2.html

    r14449 r14512  
    5050<div id="mainwindow"> 
    5151<h1>Run Perl 6 now -- in your browser!</h1> 
    52 <p>This live web terminal runs the latest development snapshot of 
    53 the <a href="http://www.pugscode.org">pugs</a> interpreter for <a 
     52<p>This live web terminal runs the <a href="http://www.pugscode.org">pugs</a> interpreter for <a 
    5453href="http://dev.perl.org/perl 6/">Perl&nbsp;6</a>. For more details, read the <a 
    5554href="http://feather.perl6.nl/~andara/runpugs/">info page</a>. 
    5655</p> 
    57 <form style="text-align: left" id="term" name="terminal" 
    58 action="/cgi-bin/runpugs2" method="POST">                   
     56<p>By default, the Pugs session will use the <a 
     57href="http://search.cpan.org/search?query=perl6%3A%3Apugs&mode=module">latest 
     58release</a>. To use the latest development snapshot, change the setting 
     59below.</p> 
    5960                                
    60 <input type="hidden" name="testing" value="_TESTING_"> 
     61<form id="term" name="terminal" action="/cgi-bin/runpugs2" method="POST">                   
    6162<input type="hidden" name="prompt" value="_PROMPTW_"> 
    6263<input type="hidden" name="sessionid" value=""> 
     64<input type="hidden"    name="ia" value="1"> 
    6365<input type="hidden"    name="action" value="runpugs"> 
    64 <!--<label for="cmd">Interactive Pugs Session<br>--> 
    65 <h2>Interactive Pugs Session</h2> 
     66<input type="radio" id="rel" value="0" name="reldev" _REL_ ><label 
     67for="rel">Release</label>&nbsp;&nbsp; 
     68<input type="radio" id="dev" value="1" name="reldev" _DEV_ ><label for="dev">Development</label> 
     69<br><br> 
     70<span class="tabon">Interactive Pugs Session</span> 
     71&nbsp;&nbsp;<a class="taboff" href="/cgi-bin/runpugs2?ia=0">Run a Perl 6 Script</a> 
    6672<div id="termwindow"> 
    67 <select name="history" id="hist" onChange="select_enter()"><!--onKeyPress="return 
    68 select_enter(this,event)">--> 
     73<select name="history" id="hist" onChange="select_enter()"> 
    6974<option value="">--- Recent commands ---</option> 
    7075_HIST_ 
    7176</select> 
    7277<br> 
    73 <!-- 
    74 <span class="prompt"> 
    75 _PROMPTW_ 
    76 </span> 
    77 <span class="termfont"> 
    78 _CMDW_ 
    79 </span> 
    80 <br> 
    81 --> 
    8278<textarea readonly id="output" name="output" rows="_NROWS_" cols="80" wrap="virtual"> 
    8379_REPLYW_ 
  • misc/runpugs/htdocs/runpugs.css

    r14449 r14512  
    88    } 
    99H2 { font-weight: bold; font-size: 12pt} 
    10 LABEL {font-weight: bold; } 
     10LABEL {font-weight: normal; } 
     11FIELDSET {border: solid white 0px}; 
     12LEGEND {font-weight:bold; text-align: center; } 
    1113.copyright {font-size: 9pt} 
    1214.warning { 
     
    1416padding: 5px; 
    1517} 
     18.tabon  
     19{ 
     20font-weight:bold; 
     21    background-color: #f2f2f0; 
     22    border: solid 2px #204a87; 
     23    padding: 2px; 
     24    padding-bottom: 0px; 
     25    margin-top: 10px;  
     26 
     27} 
     28.taboff { 
     29font-weight:bold; 
     30    background-color: #c2c2c0; 
     31color: gray; 
     32    border: solid 2px #204a87; 
     33    padding: 2px; 
     34    padding-bottom: 0px; 
     35    margin-top: 10px;  
     36} 
    1637#mainwindow { 
    1738width: 85ex; /*750px */ 
    1839} 
    1940#hist { 
    20  width: 100%; /*750px; */ 
    21 font-family: "Andale Mono", courier, fixed, monospace; 
    22 font-weight: normal; 
    23 font-size: 10pt; 
    24  color: #204a87; 
    25 border: solid 0px #204a87; 
     41    width: 100%; /*750px; */ 
     42    font-family: "Andale Mono", courier, fixed, monospace; 
     43    font-weight: normal; 
     44    font-size: 10pt; 
     45    color: #204a87; 
     46    border: solid 0px #204a87; 
    2647    background-color: #f2f2f0; 
    2748    padding-bottom: 5px; 
    2849} 
     50.term { 
     51    background-color: #f2f2f0; 
     52    border: solid 2px #204a87; 
     53    padding: 5px; 
     54} 
     55#outputwindow { 
     56    height=20ex; 
     57} 
     58#editorwindow { 
     59    height: 50ex; /*400px;*/ 
     60} 
     61 
    2962#termwindow { 
    3063    height: 45ex; /*400px;*/ 
    3164    background-color: #f2f2f0; 
    32         border: solid 2px #204a87; 
     65    border: solid 2px #204a87; 
    3366    padding: 5px; 
    3467} 
     
    3669    font-family: "Andale Mono", courier, fixed, monospace; 
    3770    font-size: 11pt; 
    38 font-weight: bold; 
     71    font-weight: bold; 
    3972    line-height: 12pt; 
    4073    color: #204a87; 
     
    4578    font-family: "Andale Mono", courier, fixed, monospace; 
    4679    font-size: 11pt; 
    47 font-weight: normal; 
     80    font-weight: normal; 
    4881    line-height: 12pt; 
    4982    color: #204a87; 
     
    6194        border: solid 0px #f2f2f0; 
    6295} 
    63 #output { 
    64 width: 100%; 
     96#output,#script { 
     97    width: 100%; 
    6598    font-family: "Andale Mono", courier, fixed, monospace; 
    6699    font-size: 11pt; 
     
    69102    color: #204a87; 
    70103    background-color: #f2f2f0; 
    71         border: solid 0px #f2f2f0; 
    72         /* for IE */ 
    73         overflow: visible; 
     104    border: solid 0px #f2f2f0; 
     105    /* for IE */ 
     106    overflow: visible; 
    74107} 
    75108#cmd { 
     
    88121A:visited, A.bold:visited { text-decoration: underline; color: #660066} 
    89122A:hover, A.bold:hover { text-decoration: underline; color: #000099} 
    90  
     123A.taboff:link, A.taboff:active,A.taboff:visited {text-decoration: none; color: #333333} 
  • misc/runpugs/lib/Web/Terminal/Dispatcher.pm

    r14449 r14512  
    2424        my $id = shift; 
    2525        my $ip = shift; 
    26         my $cmds  = shift; 
     26    my $app=shift; 
     27    my $interactive=shift; 
     28    my $cmds  = shift; 
    2729        my $host = $Web::Terminal::Settings::host; 
    2830        my $port = $Web::Terminal::Settings::port; 
     
    6668        return "Sorry, the pugs server is not running."; 
    6769    } else { 
    68         my $msg = YAML::Syck::Dump({ id=> $id, ip=> $ip, cmd=> $cmd}); 
     70        my $msg = YAML::Syck::Dump({ id=> $id, ip=> $ip, app=>$app,ia=>$interactive,cmd=> $cmd}); 
    6971        $conn->send_now($msg); 
    7072        ( my $rmesg, my $err ) = $conn->rcv_now(); 
  • misc/runpugs/lib/Web/Terminal/Server.pm

    r14449 r14512  
    3737        my $id  = shift; 
    3838    my $ip=shift; 
     39    my $app=shift; 
     40    my $ia=shift; 
    3941        my $cmd = shift; 
    4042if(scalar(keys %terminals)>$Web::Terminal::Settings::nsessions){ # each pugs takes 1% of feather's MEM! 
     
    4244} else { 
    4345        if ( exists $terminals{$id} ) { 
    44     print "$id exists\n"; 
    4546    if ($terminals{$id}->{pid}) {     
    4647    $terminals{$id}->{called}=time; 
     48        #if swap to other app 
     49        if ($app != $terminals{$id}->{'app'}) { 
     50                 &killterm($id); 
     51                        $terminals{$id} = new 
     52                Web::Terminal::Server::Session(app=>$app,ia=>$ia,id=>$id,cmds=>$cmd); 
     53                        my $term = $terminals{$id}; 
     54                    $term->{called}=time; 
     55                my $init= $term->{'init'}; 
     56                my $error= $term->{'error'}; 
     57                if ($error==1) { # Failed to create a new terminal 
     58                $sessions_per_ip{$ip}--; 
     59                delete $terminals{$id}; 
     60                }  
     61                return $init; 
     62        } 
    4763                my $term  = $terminals{$id}; 
    4864        push  @{$term->{recent}},$cmd unless $cmd=~/^\s*$/; 
     
    5268                my $lines = $term->write($cmd); 
    5369                if ( $cmd eq $Web::Terminal::Settings::quit_command ) { 
    54             my $pid= $terminals{$id}->{pid}; 
    55             print "Quit $id ($pid)\n"; 
    56                         delete $terminals{$id}; 
    57             if ($pid) { 
    58                 kill 9,$pid; 
    59             } 
     70            &killterm($id); 
    6071            $sessions_per_ip{$ip}--; 
    6172            return $lines; 
    62 #               } 
    63         #if ($lines=~/Aborted/s) { 
    6473        } elsif ($terminals{$id}->{error}==1) { 
    65              my $pid= $terminals{$id}->{pid}; 
    66              delete $terminals{$id}; 
    67             if ($pid) { 
    68                 kill 9,$pid; 
    69            } 
     74            &killterm($id); 
    7075            $sessions_per_ip{$ip}--; 
    7176        } 
     
    8186        print "New $id\n"; 
    8287            $sessions_per_ip{$ip}++; 
    83                 $terminals{$id} = new Web::Terminal::Server::Session(); 
     88            print "$app $ia $id $cmd\n"; 
     89                $terminals{$id} = new 
     90            Web::Terminal::Server::Session(app=>$app,ia=>$ia,id=>$id,cmds=>$cmd); 
    8491            $terminals{$id}->{called}=time; 
    8592            $terminals{$id}->{ip}=$ip; 
    8693                my $term = $terminals{$id}; 
    87             my $init= $term->{'output'}; 
     94            my $output= $term->{'output'}; 
    8895            my $error= $term->{'error'}; 
    89             if ($error==1) { # Failed to create a new terminal 
     96            if ($error==1 or $ia==0) { # Failed to create a new terminal 
    9097                $sessions_per_ip{$ip}--; 
    9198                delete $terminals{$id}; 
    9299            } 
    93             return $init; 
     100            return $output; 
    94101        } 
    95102        } 
     
    107114            my $ip=$mesgref->{ip}; 
    108115            my $cmd=$mesgref->{cmd}; 
     116            my $app=$mesgref->{app}; 
     117            my $ia=$mesgref->{ia}; 
    109118#            $cmd=pack("U0C*", unpack("C*",$cmd)); 
    110119            my $pid=0; 
     
    115124            print scalar(localtime)," : $nsess : $ip : $id : $pid > ",$cmd,"\n"; 
    116125            print LOG2 scalar(localtime)," : $nsess : $ip : $id : $pid > ",$cmd,"\n"; 
    117                         my $lines = &termhandler( $id, $ip, $cmd ); 
     126                        my $lines = &termhandler( $id, $ip, $app,$ia, $cmd ); 
    118127            my @history=(''); #   --- Recent commands ---'); 
    119128            my $prompt=$Web::Terminal::Settings::prompt; 
     
    164173        kill 'USR1',getppid(); 
    165174    } 
    166     system("killall $Web::Terminal::Settings::command"); 
     175    #system("killall $Web::Terminal::Settings::commands[$app]"); 
    167176    chdir $Web::Terminal::Settings::cgi_path; 
    168177    exec("$Web::Terminal::Settings::perl ../bin/$Web::Terminal::Settings::server"); 
     
    197206    } 
    198207} 
     208sub killterm { 
     209    my $id=shift; 
     210    my $pid= $terminals{$id}->{pid}; 
     211    delete $terminals{$id}; 
     212    if ($pid) { 
     213        kill 9,$pid; 
     214    } 
     215} 
    199216 
    2002171; 
  • misc/runpugs/lib/Web/Terminal/Server/Session.pm

    r14449 r14512  
    1919        my $class    = ref($invocant) || $invocant; 
    2020        my $self     = {@_}; 
    21         #my $prompt = '/\>\ /'; 
    2221    my $prompt ='/'.$Web::Terminal::Settings::prompt.'/'; 
    2322    $self->{'prompt'}=$prompt; 
    24    # my $prompt= '/'.$Web::Terminal::Settings::init_pattern.'/'; 
    25     #my $prompt= '/'.$Web::Terminal::Settings::prompt_pattern.'/'; 
    2623    $self->{'error'}=0; 
    2724    $self->{'recent'}=[]; 
    2825        ## Start pugs 
    29 #    $ENV{PUGS_SAFEMODE}=1;# Must be in CGI script! 
    30         ( $self->{'pty'},$self->{'pid'} ) = 
    31     &spawn($Web::Terminal::Settings::command);    # spawn() defined below 
     26    my $app=$self->{'app'}; 
     27    my $command=$Web::Terminal::Settings::commands[$app]; 
     28    if ($self->{'ia'}==0) { 
     29        #1. Create a file with the content of $cmd using $id.p6 for name, store in data 
     30        my $id=$self->{'id'}; 
     31        open(P6,">$Web::Terminal::Settings::tmp_path/$id.p6") or ($self->{'error'}=1); 
     32        if($self->{'error'}==0) { 
     33        print P6 $self->{'cmds'}; 
     34        close P6; 
     35            $command.=" $Web::Terminal::Settings::tmp_path/$id.p6"; 
     36        } 
     37    } 
     38        ( $self->{'pty'},$self->{'pid'} ) = &spawn($command);    # spawn() defined below 
    3239    if ( $self->{'pty'}==-1 and  $self->{'pid'}==0) { 
    3340        $self->{'output'}= "\nThere was a problem starting pugs. Please try again later."; 
    3441        $self->{'error'}=1; 
     42        if ($self->{'ia'}==0) { 
     43            my $id=$self->{'id'}; 
     44            unlink "$Web::Terminal::Settings::tmp_path/$id.p6"; 
     45        } 
    3546    } else { 
    3647        ## Create a Net::Telnet object to perform I/O on pugs's tty. 
     
    4354                -cmd_remove_mode => 0, 
    4455        ); 
    45     my $error=''; 
     56#    my $error=''; 
    4657#    ( my $p, my $m ) = $self->{'pugs'}->waitfor( 
    4758#               -match   => $self->{'pugs'}->prompt, 
     
    5566        bless($self,$class); 
    5667    my $m=$self->readlines(); 
    57       #die "starting pugs failed: ", $self->{'pugs'}->lastline; 
    58         $self->{'output'}= $m; #$p.$m.$error;#$self->{'pugs'}->prompt; 
     68      if ($self->{'error'}==1) { 
     69          # should close the TTY 
     70          $self->{'pty'}->close() unless ($self->{'pty'}==-1); 
     71          $self->{'pugs'}->close(); 
     72      } 
     73        if ($self->{'ia'}==0) { 
     74        my $id=$self->{'id'}; 
     75        unlink "$Web::Terminal::Settings::tmp_path/$id.p6"; 
     76          # should close the TTY 
     77          $self->{'pty'}->close() unless ($self->{'pty'}==-1); 
     78          $self->{'pugs'}->close(); 
     79        } 
     80        $self->{'output'}= $m;  
    5981    } 
    6082        #bless($self,$class); 
     
    6587        my $obj = shift; 
    6688        my $ps = '';