LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-22-2009, 08:47 AM   #1
kofucii
Member
 
Registered: May 2007
Location: Bulgaria
Distribution: Slackware, SCO Unix
Posts: 62

Rep: Reputation: 20
Simple CGI Script to redirect


Hello,
how can I create cgi redirect script, who can import linux environment variable as IP, and redirect to this IP and some port. I;ve tried this, but it doesn't seem to work:

#!/usr/bin/perl -w
use strict;
use warnings;

my $ip = $ENV{'MYIPADDRESS'};
my $port = ":8888";
my $URL = "http://$ip$port";

print "Status: 302 Moved\nLocation: $URL\n\n";
 
Old 08-22-2009, 09:06 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,645

Rep: Reputation: 1539Reputation: 1539Reputation: 1539Reputation: 1539Reputation: 1539Reputation: 1539Reputation: 1539Reputation: 1539Reputation: 1539Reputation: 1539Reputation: 1539
Replace MYIPADDRESS with HTTP_HOST.
Btw you don't need ":" in the port variable, just put ":" in the new url like "my $URL = "http://$ip:$port";
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
calling CGI script in CGI script ravi_chobey Programming 3 03-19-2009 12:36 PM
Simple redirect question? scsi.king Programming 3 04-24-2007 01:44 AM
why this simple cgi script doesnot work ? . adam_blackice Programming 4 04-04-2007 10:50 AM
Why doesnt my simple html post to cgi script work? ginda Linux - Networking 10 03-15-2005 03:32 PM
writing a cgi to redirect to another webpage JustinHoMi Programming 2 09-28-2001 08:08 PM


All times are GMT -5. The time now is 07:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration