open (RES, "/usr/bin/top -bs -n 1 |");

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default Re: open (RES, "/usr/bin/top -bs -n 1 |");

    Sandrine CHEN <sandrinechen@hotmail.com> wrote in comp.lang.perl.misc:
    > 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!
    So obviously there is a difference between the two machines.

    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.
    > ____________________________________________
    > #!/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 |");
    You should check the return value of open(). That may give you
    a first hint.
    > while (<RES>) {
    > print $_,"<br>";
    > }
    > close RES;
    >
    > print "</body>";
    > ____________________________________________
    >
    > thank u very much...
    > print "</html>";
    Anno
    Anno Siegel Guest

  4. #3

    Default Re: open (RES, "/usr/bin/top -bs -n 1 |");

    Sandrine CHEN <sandrinechen@hotmail.com> wrote:
    >
    > open (RES, "/usr/bin/top -bs -n 1 |");
    > while (<RES>) {
    > print $_,"<br>";
    > }
    > close RES;
    >
    The error-checking for piped open works like this:

    #
    # 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139