?
Solved

Posting a form without changing the current HTML page.

Posted on 1997-07-10
2
Medium Priority
?
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
pc012197 earned 200 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

771 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