Sponsored Content
Full Discussion: PERL: ping and e-mail
Top Forums Shell Programming and Scripting PERL: ping and e-mail Post 34931 by perleo on Saturday 22nd of March 2003 06:21:26 AM
Old 03-22-2003
still wont work Smilie

keeps printing the results onto screen.

can you put thr results into an array lik this

foreach (@pinglist) {

system ("ping $_ \@results")
}

???
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl Ping Determine Success or Fail

I know how to ping in Perl. That is easy. What I am wondering is if there is a way for Perl to determine whether the ping was successful or not. Or do I need to save the results out and parse the results seperately looking for the #of tries and successful revieves. Thanks. (1 Reply)
Discussion started by: gdboling
1 Replies

2. Shell Programming and Scripting

Perl telnet to cisco router and compare the ping ms

All Please help, i will telnet to router to obain the ping status and compare, if higher than normal latency, i will have further action.. if i do the telent and in perl script then .... e.g the result i obtain from the router will be =' Success rate is 100 percent (5/5), round-trip... (4 Replies)
Discussion started by: optimus
4 Replies

3. Shell Programming and Scripting

perl ping script

Dear All Any one able been writing any command ping in perl??basically i want to wring ping script to send 1000 packet ping then initiate "Ctrl C' terminal to ping example below:-] #!/usr/local/bin/perl $r=`/bin/ping 172.23.11.254`; Thank You ---------- Post updated at 10:27 PM ----------... (2 Replies)
Discussion started by: netxus
2 Replies

4. Shell Programming and Scripting

perl return ips after successful ping

Hi, I have this script in ksh, what it does is loop every ip in the nodes_nso and produced another variable up_nodes_nso of only ip's that are up. nodes_nso=$(cat /var/tmp/nodes.txt) echo "ICMP Tests:" up_nodes_nso="" for ip in ${nodes_nso} ; do ping ${ip} 3 > /dev/null if ; then ... (1 Reply)
Discussion started by: borderblaster
1 Replies

5. Programming

Perl Ping Loop

Hi All i have an issue with ping, we are using dhcp and so if the machine has been offline and i ping it, i get " ping: unknown host <hostname> is there a way i can stick a loop somewhere so it would keep trying when it got the unknown host error and then when the machine came back online... (2 Replies)
Discussion started by: ab52
2 Replies

6. Shell Programming and Scripting

Ping and Perl

Hi There i have little situation that i could us some help with. We have a dhcp server, but the problem is if that a machine has been offline for a while it loose it's lease and so if you ping it you get unknown host if there a way using perl that it will continue to try and ping it, even tho... (1 Reply)
Discussion started by: ab52
1 Replies

7. Shell Programming and Scripting

Animation Ping on Solaris Like Cisco Ping

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

8. Shell Programming and Scripting

Perl : ping for multiple IPs not working

I have written perl ping program to ping list of IPs one by one and print the status.But each and every time it is showing the status as Pass for all IPs even though the IP is wrong. multipleip.pl use Net::Ping; $p = Net::Ping->new(); $ifile="inventory.txt"; ... (2 Replies)
Discussion started by: scriptscript
2 Replies

9. Shell Programming and Scripting

Perl : code on ping showing difference result

Hi all, I am using the below code to ping a code and print whehter the connection is successful or not. use Net::Ping; $p = Net::Ping->new(); my $host = "x.x.x.x"; # print "$host is alive.\n" if $p->ping($host); if ($p->ping($host,3)) { print... (0 Replies)
Discussion started by: scriptscript
0 Replies

10. Programming

Ping test sends mail when ping fails

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
MONGOCOLLECTION.FIND(3) 						 1						   MONGOCOLLECTION.FIND(3)

MongoCollection::find - Queries this collection, returning aMongoCursorfor the result set

SYNOPSIS
public MongoCursor MongoCollection::find ([array $query = array()], [array $fields = array()]) DESCRIPTION
PARAMETERS
o $query - The fields for which to search. MongoDB's query language is quite extensive. The PHP driver will in almost all cases pass the query straight through to the server, so reading the MongoDB core docs on find is a good idea. Warning Please make sure that for all special query operators (starting with $) you use single quotes so that PHP doesn't try to replace "$exists" with the value of the variable $exists. o $fields - Fields of the results to return. The array is in the format array('fieldname' => true, 'fieldname2' => true). The _id field is always returned. RETURN VALUES
Returns a cursor for the search results. EXAMPLES
Example #1 MongoCollection.find(3) example This example demonstrates basic search options. <?php $m = new MongoClient(); $db = $m->selectDB('test'); $collection = new MongoCollection($db, 'produce'); // search for fruits $fruitQuery = array('Type' => 'Fruit'); $cursor = $collection->find($fruitQuery); foreach ($cursor as $doc) { var_dump($doc); } // search for produce that is sweet. Taste is a child of Details. $sweetQuery = array('Details.Taste' => 'Sweet'); echo "Sweet "; $cursor = $collection->find($sweetQuery); foreach ($cursor as $doc) { var_dump($doc); } ?> The above example will output: array(4) { ["_id"]=> object(MongoId)#7(1) { ["$id"]=> string(24) "50a87dd084f045a19b220dd6" } ["Name"]=> string(5) "Apple" ["Type"]=> string(5) "Fruit" ["Details"]=> array(2) { ["Taste"]=> string(5) "Sweet" ["Colour"]=> string(3) "Red" } } array(4) { ["_id"]=> object(MongoId)#8(1) { ["$id"]=> string(24) "50a87de084f045a19b220dd7" } ["Name"]=> string(5) "Lemon" ["Type"]=> string(5) "Fruit" ["Details"]=> array(2) { ["Taste"]=> string(4) "Sour" ["Colour"]=> string(5) "Green" } } Sweet: array(4) { ["_id"]=> object(MongoId)#7(1) { ["$id"]=> string(24) "50a87dd084f045a19b220dd6" } ["Name"]=> string(5) "Apple" ["Type"]=> string(5) "Fruit" ["Details"]=> array(2) { ["Taste"]=> string(5) "Sweet" ["Colour"]=> string(3) "Red" } } See MongoCursor for more information how to work with cursors. Example #2 MongoCollection.find(3) example This example demonstrates how to search for a range. <?php $m = new MongoClient(); $db = $m->selectDB('test'); $collection = new MongoCollection($db, 'phpmanual'); // search for documents where 5 < x < 20 $rangeQuery = array('x' => array( '$gt' => 5, '$lt' => 20 )); $cursor = $collection->find($rangeQuery); foreach ($cursor as $doc) { var_dump($doc); } ?> The above example will output: array(2) { ["_id"]=> object(MongoId)#10(1) { ["$id"]=> string(24) "4ebc3e3710b89f2349000000" } ["x"]=> int(12) } array(2) { ["_id"]=> object(MongoId)#11(1) { ["$id"]=> string(24) "4ebc3e3710b89f2349000001" } ["x"]=> int(12) } See MongoCursor for more information how to work with cursors. Example #3 MongoCollection.find(3) example using $where This example demonstrates how to search a collection using javascript code to reduce the resultset. <?php $m = new MongoClient(); $db = $m->selectDB('test'); $collection = new MongoCollection($db, 'phpmanual'); $js = "function() { return this.name == 'Joe' || this.age == 50; }"; $cursor = $collection->find(array('$where' => $js)); foreach ($cursor as $doc) { var_dump($doc); } ?> The above example will output: array(3) { ["_id"]=> object(MongoId)#7(1) { ["$id"]=> string(24) "4ebc3e3710b89f2349000002" } ["name"]=> string(3) "Joe" ["age"]=> int(20) } Example #4 MongoCollection.find(3) example using $in This example demonstrates how to search a collection using the $in operator. <?php $m = new MongoClient(); $db = $m->selectDB('test'); $collection = new MongoCollection($db, 'phpmanual'); $cursor = $collection->find(array( 'name' => array('$in' => array('Joe', 'Wendy')) )); ?> The above example will output: array(3) { ["_id"]=> object(MongoId)#7(1) { ["$id"]=> string(24) "4ebc3e3710b89f2349000002" } ["name"]=> string(3) "Joe" ["age"]=> int(20) } Example #5 Getting results as an array This returns a MongoCursor. Often, when people are starting out, they are more comfortable using an array. To turn a cursor into an array, use the iterator_to_array(3) function. <?php $m = new MongoClient(); $db = $m->selectDB('test'); $collection = new MongoCollection($db, 'phpmanual'); $cursor = $collection->find(); $array = iterator_to_array($cursor); ?> The above example will output: array(3) { ["4ebc40af10b89f5149000000"]=> array(2) { ["_id"]=> object(MongoId)#6(1) { ["$id"]=> string(24) "4ebc40af10b89f5149000000" } ["x"]=> int(12) } ["4ebc40af10b89f5149000001"]=> array(2) { ["_id"]=> object(MongoId)#11(1) { ["$id"]=> string(24) "4ebc40af10b89f5149000001" } ["x"]=> int(12) } ["4ebc40af10b89f5149000002"]=> array(3) { ["_id"]=> object(MongoId)#12(1) { ["$id"]=> string(24) "4ebc40af10b89f5149000002" } ["name"]=> string(3) "Joe" ["age"]=> int(20) } } Using iterator_to_array(3) forces the driver to load all of the results into memory, so do not do this for result sets that are larger than memory! Also, certain system collections do not have an _id field. If you are dealing with a collection that might have documents without _ids, pass FALSE as the second argument to iterator_to_array(3) (so that it will not try to use the non-existent _id values as keys). SEE ALSO
MongoCollection.findOne(3), MongoCollection.insert(3), MongoDB core docs on find.. PHP Documentation Group MONGOCOLLECTION.FIND(3)
All times are GMT -4. The time now is 12:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy