01-05-2009
How do I ping each element
@listip is a list of ips
my $PING = "/usr/sbin/ping";
for ($lindex = 0; $lindex <= $#listip; $lindex++) {
print $listip[$lindex] . "\n";
$PING $listip[$lindex] ;
}
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am looking for a way to get the last element of a cut command
ex.
$pwd
/remote/username/dir1/dir2/dir3
$pwd | cut -f3 -d/
username
I need to extract "dir3" (last one) no matter whichever position it is.
Thanks,
sskb (3 Replies)
Discussion started by: oldtrash
3 Replies
2. Shell Programming and Scripting
Hi,
I develop simple animation ping script on Solaris Platform. It is like Cisco ping.
Examples and source code are below.
bash-3.00$ gokcell 152.155.180.8 30
Sending 30 Ping Packets to 152.155.180.8
!!!!!!!!!!!!!.!!!!!!!!!!!!!!!.
% 93.33 success... % 6.66 packet loss...... (1 Reply)
Discussion started by: gokcell
1 Replies
3. Shell Programming and Scripting
I want to check if every <Part> element has corresponding <Description> in this sample XML.
....<Lot Of XML>
<Inv lineNumber="2">
<Item>
... (4 Replies)
Discussion started by: kchinnam
4 Replies
4. Shell Programming and Scripting
Hi, i want the loop to move to 3rd item, when it encounters 2 while runing
for i in 1 2 3 4 5 6
do
if
then
#jump to element 3
else
echo $i
fi
done
o/p
1
3
4
5
6 (4 Replies)
Discussion started by: sam05121988
4 Replies
5. Shell Programming and Scripting
Hi all
I have file with columns
F3 pathway CPS
F2
H2
H4
H5
H6 no pathway CMP
H7
H8
H9
H10
My expected output is
F3 pathway CPS
F2 pathway CPS (10 Replies)
Discussion started by: Priyanka Chopra
10 Replies
6. Shell Programming and Scripting
Hi
I am using perl to ping a list of nodes - with script below :
$p = Net::Ping->new("icmp");
if ($p->ping($host,1)){
print "$host is alive.\n";
}
else {
print "$host is unreacheable.\n";
}
$p->close();... (4 Replies)
Discussion started by: tavanagh
4 Replies
7. UNIX for Advanced & Expert Users
This question is for someone that's more familiar with Array Element.
I need to know if the maximum array element that can be assigned is 1024 and if its so, Is there a workaround solution when the counter exceeded 1024?
param_array="$param_nam"
counter=$counter+1
#to avoid space... (3 Replies)
Discussion started by: cumeh1624
3 Replies
8. Programming
help with bash script!
im am working on this script to make sure my server will stay online, so i made this script..
HOSTS="192.168.138.155"
COUNT=4
pingtest(){
for myhost in "$@"
do
ping -c "$COUNT" "$myhost" &&return 1
done
return 0
}
if pingtest $HOSTS
#100% failed... (4 Replies)
Discussion started by: mort3924
4 Replies
lrange(n) Tcl Built-In Commands lrange(n)
__________________________________________________________________________________________________________________________________________________
NAME
lrange - Return one or more adjacent elements from a list
SYNOPSIS
lrange list first last
_________________________________________________________________
DESCRIPTION
List must be a valid Tcl list. This command will return a new list consisting of elements first through last, inclusive. The index values |
first and last are interpreted the same as index values for the command string index, supporting simple index arithmetic and indices rela- |
tive to the end of the list. If first is less than zero, it is treated as if it were zero. If last is greater than or equal to the number
of elements in the list, then it is treated as if it were end. If first is greater than last then an empty string is returned. Note:
"lrange list first first" does not always produce the same result as "lindex list first" (although it often does for simple fields that are
not enclosed in braces); it does, however, produce exactly the same results as "list [lindex list first]"
EXAMPLES
Selecting the first two elements:
% lrange {a b c d e} 0 1
a b
Selecting the last three elements:
% lrange {a b c d e} end-2 end
c d e
Selecting everything except the first and last element:
% lrange {a b c d e} 1 end-1
b c d
Selecting a single element with lrange is not the same as doing so with lindex:
% set var {some {elements to} select}
some {elements to} select
% lindex $var 1
elements to
% lrange $var 1 1
{elements to}
SEE ALSO
list(n), lappend(n), lindex(n), linsert(n), llength(n), lsearch(n), lset(n), lreplace(n), lsort(n), string(n) |
KEYWORDS
element, list, range, sublist
Tcl 7.4 lrange(n)