Ask a Question related to PERL Miscellaneous, Design and Development.
-
Sandrine CHEN #1
open (RES, "/usr/bin/top -bs -n 1 |");
Thank you to tell me why:
I have one program like following, it could display results on HTML
page on one machine, but not on another which has the same kernel of
2.4.18-3, Redhat Linux, I star to wonder is it that i haven't written
the program in a way more popular, or there is other point that i need
to check or take care?
What's more, on the same machine(that result couldn't display), if i
run the script manually under command line, it couldn't display
results. :( Why!
____________________________________________
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "<html>\n";
print "<test of result>";
print "<body>";
open (RES, "/usr/bin/top -bs -n 1 |");
while (<RES>) {
print $_,"<br>";
}
close RES;
print "</body>";
____________________________________________
thank u very much...
print "</html>";
Sandrine CHEN Guest
-
How to add "..." button to a property to open up "File Open"?
I am creating a control and thinking about adding a property to the control. I will like a "..." button shown next to the value of this property... -
PDF and program won't open; "Error in Acrord32" "This program has performed an illegal operation and
I recently had a browser hijacker. Fixed it with Norton and Lavasoft. Now, after downloading new Reader 6.0, I can't open anything. Only gives... -
Force GetUrl to open dialog box "open or save"
I'm triyng to link several buttons to several external 3D .step and .igs files. I needed Flash to open dialog box "Open or save", but what hapens... -
animation "open" onPress( animation "close" ) go to Frame "myFrame"
I have searched hi and low for the answer and nothing has helped me as of yet. My Main timeline is sectioned off by keyframes that are 10 frames... -
Unable To Open File "..." Because It Is Already Open With Write Permission
I am trying to open a page for offline browsing and whenever I try to open a particular link I get this "Unable To Open File '...' Because It Is... -
Anno Siegel #2
Re: open (RES, "/usr/bin/top -bs -n 1 |");
Sandrine CHEN <sandrinechen@hotmail.com> wrote in comp.lang.perl.misc:
So obviously there is a difference between the two machines.> Thank you to tell me why:
>
> I have one program like following, it could display results on HTML
> page on one machine, but not on another which has the same kernel of
> 2.4.18-3, Redhat Linux, I star to wonder is it that i haven't written
> the program in a way more popular, or there is other point that i need
> to check or take care?
>
> What's more, on the same machine(that result couldn't display), if i
> run the script manually under command line, it couldn't display
> results. :( Why!
What does it mean when you say "couldn't display results"? Does the
program show no output at all? Does it show part of the expected
output, and if so, where does it stop. Does the program finish normally,
finish with a return code, or not finish at all (hang)?
Without you telling us more, there is no chance of guessing what the
difference may be.
You should check the return value of open(). That may give you> ____________________________________________
> #!/usr/bin/perl -w
>
> print "Content-type: text/html\n\n";
> print "<html>\n";
> print "<test of result>";
> print "<body>";
>
> open (RES, "/usr/bin/top -bs -n 1 |");
a first hint.
Anno> while (<RES>) {
> print $_,"<br>";
> }
> close RES;
>
> print "</body>";
> ____________________________________________
>
> thank u very much...
> print "</html>";
Anno Siegel Guest
-
Steve Grazzini #3
Re: open (RES, "/usr/bin/top -bs -n 1 |");
Sandrine CHEN <sandrinechen@hotmail.com> wrote:
The error-checking for piped open works like this:>
> open (RES, "/usr/bin/top -bs -n 1 |");
> while (<RES>) {
> print $_,"<br>";
> }
> close RES;
>
#
# open can also fail on fork(), pipe() or exec()
#
open my $top, '-|', qw(/usr/bin/top -bs -n 1)
or die "Couldn't start top: $!";
print while <$top>;
#
# close also fails if wait() yields nonzero exit status
#
close($top) or die "close: ", $! || $?;
Without any error checks, of course you don't know what went wrong.
If the open() fails, then perl will give you the right error. If
"top" is failing and you want to capture the diagnostic (i.e. not just
the wait() status) use IPC::Open3 to catch its stderr.
--
Steve
Steve Grazzini Guest



Reply With Quote

