in reply to Re: Unable to execute URL from perl/cgi script
in thread Unable to execute URL from perl/cgi script

Thanks for the reply. Whenever I am running the script,new window is opening but now the correct URL which is mentioned in the code. I am not sure where the problem exists exactly but the code is running fine and no error is found in the new window. Basic nutshell is that I have to open the URL whenever the script is executed.

#!/usr/bin/perl use CGI ':standard'; use HTTP::Request; use LWP::Simple qw/get/; #use LWP::UserAgent; print header(); print start_html(); $a=param('$selected_rows.Location'); $a =~ s/\D//g; $a =~ s/^[0]+//g; $url = "http://operationalintelligence/Site/sitevisit.php?site=$a&type +=a&days=90"; #$url = 'https://10.204.16.17:16316/ibm/console/login.do?action=secure +'; my $data=get($url); print end_html();

Replies are listed 'Best First'.
Re^3: Unable to execute URL from perl/cgi script
by Anonymous Monk on Feb 06, 2015 at 21:40 UTC

    Sorry but I'm still not quite clear on what you are trying to do. But I'm going to wager two guesses: 1. Do you want to fetch the page from the URL and display it to the user? In that case, you could drop the start_html() and end_html() calls and simply say print $data; - However, note your script currently does no error handling, and this would only reliably work for plain HTML pages; if you have images, CSS files, etc. those may or may not work correctly depending on how they are referenced in the HTML.

    Or, 2. Do you want to redirect the user to the new URL? In that case, look at the redirect function from CGI (section "Generating a redirection header"), and note that you should not output anything else (i.e. no header(), no start_html(), etc.)

    Note that you really, really should be doing use warnings; use strict; at the top of your script. See Use strict and warnings.

    If I am still misunderstanding what you want to do then what might help would be if you could give a step-by-step explanation of the expected behavior of the user and your script.