--- "J. Patrick Lanigan" <[EMAIL PROTECTED]> wrote:
> Now that I have CGI working with apache on my server, I am
> experimenting.
> Anyhow, I wrote the following script and was wondering how to capture
> the output of a system call. I am trying to capture the output so
that
> I can format it for the browser.

system() returns the exit code of the command.
backticks return it's output.

system("ls foo") returns 0 if foo is there, or the code if it fails.
`ls foo` returns "foo\n" if foo exists, or nothing if there is no foo
(though in either the command might produce some kernel-based error
output...)

> #!/usr/bin/perl -w
> use strict;
> use CGI qw(:standard);
> 
> print header(), start_html("Online Manpage Accessor"), h1("Online
> Manpage
> Accessor");
> if (param()) {
>       my $manpage = param("manpage");
>       my @output = system("man $manpage"); #trying to capture,
>                                            #but it goes to the browser
> } else {
>       print hr, start_form;
>       print p("Enter manpage: ", textfield("manpage"));
>       print p(submit("lookup"), reset("clear"));
>       print end_form, hr;
> }
> print end_html();
> 
> Thanks,
> Patrick
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Reply via email to