Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Posting a form without changing the current HTML page.

Posted on 1997-07-10
2
Medium Priority
?
181 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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…
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 …
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 …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

610 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