the following code will fail when using Firefox in wondows 7 and I think windows vista:
Code:
// Now use main proxies based on odd/even
// find the 4th octet -
var ipbits=myip.split(".");
var myseg=parseInt(ipbits[3]);
// If even use proxy1 first
if(myseg==Math.floor(myseg/2)*2) {
var proxyone=chpv1;
var proxytwo=chpv2;
var proxythree=shrp1;
}
else {
// Must be odd use proxy2 first
var proxyone=chpv2;
var proxytwo=chpv1;
var proxythree=shrp1;
}
It fails because myip.split(".") will result in "ipbits" not being an array with 4 elements in it because Windows 7 (and I think Vista) returns an IPv6 address that has colons ( as separators and the values are hex strings.
Try this instead:
Code:
// split the IPv4 address into a 4 element array
var ipbits = myip.split(".");
// make sure this is an IPv4 address, which is > 1
if (ipbits.length > 1)
{
// we think we have an IPv4 address here
// grab the 4th octet and convert it to a decimal
var myseg = parseInt(ipbits[3]);
} else {
// we have a potential IPv6 address here
// split the IPv6 address into a 6 element array
var ipbits = myip.split(":");
if (ipbits.length > 1)
{
// looks like we have an IPv6 address here
// grab the 6th octet and convert it from hex to decimal
var myseg = parseInt(ipbits[5],16);
} else {
// NOT AN IPv6 either, so ODD it will be by us forcing it to a 1!!!
var myseg = 1;
}
}
// take the modulus 2 of the myseg where 1 = odd, 0 = even
var mycalcseg = myseg % 2;
if (mycalcseg == 1) {
// ODD number (mycalcseg = 1)
var proxyone = proxyONEip;
var proxytwo = proxyTWOip;
} else {
// EVEN number (mycalcseg = 0)
var proxyone = proxyTWOip;
var proxytwo = proxyONEip;
}
Hi I am trying to write a shell script that will read 4 lines from a file and put them in variables which will be used in the script.
Can someone tell me how can I read a line and put it in a variable?
I have tried this... but this does not work.
#! /bin/sh
cat yest | while read line
do... (2 Replies)
file.txt contains
------------------
sat1 1300
#sat2 2400
sat3
sat4 500
sat5
I need to write a shell script that will output like the below
#output
sat1.ksh 1300
sat3.ksh
sat4.ksh 500
sat5.ksh
my try
------- (4 Replies)
Hi ,
I wanted to know if its possible to execute a javascript function like this
E:- function js1(){
alert ("this is js1");
}
function js2(){
alert ("this is js2");
}
function js3(){
....
execthisscript(js1);
execthisscript(js2);
}
... (1 Reply)
Hi guys,
Ok first, let me explain what I want to do. I'm making a theme for the iphone, and I found a nice wallpaper slideshow script. Here is how it knows which wallpapers to use:
<script type="text/javascript">
// SLIDE ROTATION FREQUENCY (in minutes)
var slideRotation = 0.4;... (3 Replies)
Hi All,
I have a file, let's call it "info.tmp" that contains data like this ..
ABC123456
PCX333445
BCD789833
I need to read "info.tmp" and for each line add strings in a way that the final output is
put /logs/ua/dummy.trigger 'AAA00001.FTP.XXX.BLA03A01.xxxxxx(+1)'
where XXX... (5 Replies)
I have a file that has four values on each line and I'd like to give each column a variable name and then use those values in each step of a loop. In bash, I believe you could use a while loop to do this or possibly a cat command, but I am super new to programming and I'm having trouble decoding... (2 Replies)
I've got a file that looks like this (spaces before first entries intentional):
12345650-000005000GL140227 ANNUAL HELC FEE EN
22345650-000005000GL140227 ANNUAL HELC FEE EN
32345650-000005000GL140227 ANNUAL HELC FEE EN
I want to read through the file line by line,... (6 Replies)
Hello All ,
I need hello all , i need help in creating a pac file (to use in IE ). I browsed and wrote something , which is not meeting my conditions
1. in office i have to use one proxy , say PROXY1:7070 to access internet and to use client network need to add in exclusion list (advanced... (2 Replies)
Let say I have a file with variables (Test1.txt)
In Test1.txt file, it consists of
Tom is a boy
Jim is a dog
In the other scripting file (RunTest1.sh), I have
#!/bin/ksh
filename = /directory/Test1.txt
cat $filename
for i in $filename
do
print $i
done
I managed to call... (1 Reply)
Discussion started by: TestKing
1 Replies
LEARN ABOUT CENTOS
rtmon
RTMON(8) System Manager's Manual RTMON(8)NAME
rtmon - listens to and monitors RTnetlink
SYNOPSIS
rtmon [ options ] file FILE [ all | LISTofOBJECTS ]
DESCRIPTION
This manual page documents briefly the rtmon command.
rtmon listens on netlink socket and monitors routing table changes.
rtmon can be started before the first network configuration command is issued. For example if you insert:
rtmon file /var/log/rtmon.log
in a startup script, you will be able to view the full history later. Certainly, it is possible to start rtmon at any time. It prepends
the history with the state snapshot dumped at the moment of starting.
OPTIONS
rtmon supports the following options:
-Version
Print version and exit.
help Show summary of options.
file FILE [ all | LISTofOBJECTS ]
Log output to FILE. LISTofOBJECTS is the list of object types that we want to monitor. It may contain 'link', 'address', 'route'
and 'all'. 'link' specifies the network device, 'address' the protocol (IP or IPv6) address on a device, 'route' the routing table
entry and 'all' does what the name says.
-family [ inet | inet6 | link | help ]
Specify protocol family. 'inet' is IPv4, 'inet6' is IPv6, 'link' means that no networking protocol is involved and 'help' prints
usage information.
-4 Use IPv4. Shortcut for -family inet.
-6 Use IPv6. Shortcut for -family inet6.
-0 Use a special family identifier meaning that no networking protocol is involved. Shortcut for -family link.
USAGE EXAMPLES
# rtmon file /var/log/rtmon.log
Log to file /var/log/rtmon.log, then run:
# ip monitor file /var/log/rtmon.log
to display logged output from file.
SEE ALSO ip(8)AUTHOR
rtmon was written by Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>.
This manual page was written by Michael Prokop <mika@grml.org>, for the Debian project (but may be used by others).
RTMON(8)