http://www.perlmonks.org?node_id=1028778

aksusa has asked for the wisdom of the Perl Monks concerning the following question:

Hi: I am developing a form which gets the server name from the user and it get added to url and when I hit the submit button I want to open the url into a new page The below script acutally changes the url based on the clientname input

FM=`date +'%m-%d-%Y' --date="-7 day"` TM=`date +'%m-%d-%Y'` URL="http://a.com:8080/bms/healthMonitor.do?method=redirect&operation= +BackupHistorySearch&subOperation=GetReport&clientName=$1&fromDateStr= +$FM&toDateStr=$TM" echo $URL

The front end cgi script is

#!/usr/bin/perl $data_file = '/var/tmp/backup.txt'; use CGI; use Fcntl; use Getopt::Long; use CGI::Carp qw( fatalsToBrowser ); use CGI qw( :standard ); $query = new CGI; unless ($action = $query->param('action')) { $action = 'none'; } print <<"EndOfText"; Content-type: text/html <HTML> EndOfText if ($action eq 'Search') { $comment = $query->param('comment'); open(FH, ">$data_file") or die "can't open $data_file: $!"; print FH $comment; close FH or die "can't close $data_file: $!"; } open (IN, "$data_file") or die "Can't open $data_file for reading: $!" +; while (<IN>) { @host = $_; $cmd = `bash /tmp/url.sh $host[0]`; #print "$cmd"; print redirect( "$cmd" ) } close IN or die "Can't close $data_file: $!"; print <<"EndOfText"; <A NAME="form"><H2>Add Logical:</H2></A> <FORM METHOD="POST" ACTION="n.cgi"> <TABLE> <TR> <TD ALIGN="right"><STRONG>Logical:</STRONG></TD> <TD> <TEXTAREA NAME="comment" ROWS=1 COLS=30 WRAP="virtual"></TEXTAREA> </TD> </TR> <TR><TD COLSPAN=2> </TD></TR> <TR> <TD> </TD> <TD><INPUT TYPE="submit" NAME="action" VALUE="Search"></TD> </TR> </TABLE> </FORM> </BODY> </HTML> EndOfText

When I print $cmd it prints the url on the screen. Not able to redirect to new window.. Any suggestions?