Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-10-2010, 10:43 PM   #1
LQ Newbie
Registered: Jun 2010
Posts: 2

Rep: Reputation: 0
Cannot Redirect URL to another URL when the link is down with Squid

Hi guys,

i have installed squid 2.6 on my centos. i have writen a shell script to ping a network and write to a file. write '1' if network up and '0' if network down. After that,a perl script will read the file and do the redirection.Perl will redirect to a fix URL if the network down and do nothing when it up. i have put my perl script in squid.conf at url_rewrite_program /my_file_path.

below is my shell script for pinging:

while [ 1 ]

if ping -c 1 -W 1 $HOST >& /dev/null ; then
echo "$HOST is alive and kicking3" >> /etc/squid/dns_proxy
echo 1 > /etc/squid/status.txt
# service named restart
echo "$HOST is missing3" >> /etc/squid/dns_proxy
echo 0 > /etc/squid/status.txt
# service named restart
sleep 10
below is my perl.script:

while (<>)

open (MYFILE, 'status.txt');
$input = <MYFILE>;

print "$input\n";

if ($input == 0)
@X = split;
$url = $X[0];
if ($url !~ /^http:\/\/www\.google\.com/)
$_ = $url;
print "301:$_\n";
print "$url\n"
My problem is client browser are not redirect to even the network is down. It should go to the fix URL when the user click any URL in network down just appear cannot resolve host.
anyone can help me. maybe there's something wrong with my perl script.

Old 06-13-2010, 09:59 PM   #2
LQ Newbie
Registered: Jun 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Anybody can help me? i thinks there are something wrong with my perl script.


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
Squid how to redirect url gubak Linux - Networking 3 03-04-2010 03:06 PM
Using Squid/Iptables to redirect inbound web traffic to url/IP winairmvs Linux - Software 2 01-13-2010 12:41 PM
squid redirect url to different proxy aeby Linux - Software 0 08-13-2009 09:37 AM
redirect url munna_dude Linux - Software 2 02-15-2007 01:18 AM
url redirect Present Linux - Networking 4 01-26-2007 10:08 AM

All times are GMT -5. The time now is 12:11 AM.

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