Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^5: read an integer from a file

by Boldra (Deacon)
on Jun 16, 2010 at 08:21 UTC ( #844984=note: print w/ replies, xml ) Need Help??


in reply to Re^4: read an integer from a file
in thread read an integer from a file

"it doesn't work" is a singularly useless phrase in IT.

Nevertheless, I googled "squid perl redirect" and found the script I think you are using as a pattern and adapted it for what I think you are trying to do.

#!/usr/bin/perl use strict; use warnings; use IO::All; use 5.010; $| = 1; while (<>) { my $status = io('status.txt')->all; my $url = ( split )[0]; if( not $status # almost same as if( $status == 0 ) and $url =~ /\Q123.1.34.107:8080\E/ ) { say "301:http://123.1.34.107:8080/Web" } else { say $url } }
Try this outside of squid first. If it works on the command line, but with squid, it's probably permissions or the file path. Check the squid logs for more information.


- Boldra


Comment on Re^5: read an integer from a file
Download Code
Re^6: read an integer from a file
by Anonymous Monk on Jun 16, 2010 at 08:26 UTC
    #!/usr/bin/perl -- use strict; use warnings; use autodie; use 5.010; $| = 1; while (<>) { open my $fh, "<", "status.txt"; my $status = join "",<$fh>; close $fh; my $url = ( split )[0]; if( not $status # almost same as if( $status == 0 ) and $url =~ /\Q123.1.34.107:8080\E/ ) { say "301:http://123.1.34.107:8080/Web" } else { say $url } }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://844984]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-08-22 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (145 votes), past polls