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?


In reply to Perl CGI redirect by aksusa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.