Solved

Posting a form without changing the current HTML page.

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
This article will show, step by step, how to integrate R code into a R Sweave document
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now