Solved

Posting a form without changing the current HTML page.

Posted on 1997-07-10
2
176 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 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to dynamically set the form action using jQuery.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

729 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