Solved

Posting a form without changing the current HTML page.

Posted on 1997-07-10
2
173 Views
Last Modified: 2013-12-25
My Perl script executes UNIX shell commands by system(), exec() or open(). The browser always shows the result of the commands. Can I do something to "cover" this result (by printing a HTML) or simply do not return data to the browser (the page doesn't change in the browser)?
0
Comment
Question by:kenysc
2 Comments
 
LVL 3

Accepted Solution

by:
pc012197 earned 100 total points
ID: 1829028
The unix shell commands print their output to stdout and stderr. The server takes that output and includes it into the page created by the script.
The solution to your problem is to redefine stdout and stderr before invoking the shell commands:

open(SAVEOUT, ">&STDOUT");
open(SAVEERR, ">&STDERR");
open(STDOUT, ">foo.out") || die "Can't redirect stdout";
open(STDERR, ">&STDOUT") || die "Can't dup stdout";

# your unix commands go here...

close(STDOUT);
close(STDERR);

open(STDOUT, ">&SAVEOUT");
open(STDERR, ">&SAVEERR");

See also the perlfunc manpage for the open() function.

0
 
LVL 84

Expert Comment

by:ozo
ID: 1829029
You can also grab the STDOUT of commands with
      $outputfromcommand = `command`;
instead of
      $exitvalueofcommand = system("command");

See the perlop manpage for the qx operator
(or if you really want to cover it in HTML, I suppose you could
wrap it in an HTML comment...)


0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to count occurrences of each item in an array.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question