Sponsored Content
Full Discussion: dup()
Top Forums Programming dup() Post 9603 by vinchen on Tuesday 30th of October 2001 09:05:51 PM
Old 10-30-2001
Power

Thank you very much people.

Smilie
 

7 More Discussions You Might Find Interesting

1. Programming

fork() and dup()

I have met this code: switch(fork()) { case 0: close(1); dup(p); close(p); close(p); execvp(<whatever>); perror("Exec failed"); } Can anyone tell me what this piece of code does? Thx alot.. (1 Reply)
Discussion started by: AkumaTay
1 Replies

2. Programming

Understanding the purpose of dup/dup2

I'm having difficulty understanding the purposes of using dup/dup2 when involving forks. for example, if we call fork() once, that is, we are creating a child process. In what cases would we need to use dup or dup2 to duplicate the file descriptors for standard output and standard error? What... (1 Reply)
Discussion started by: Yifan_Guo
1 Replies

3. Programming

dup()

when i want to replace standard output with output file int out; out = open("out", O_WRONLY)p; dup2(out,1); What Shall I do in case of appending??? I am using here O_WRONLY TO WRITE.BUT IF i wanna append, whats the word? (5 Replies)
Discussion started by: joey
5 Replies

4. Red Hat

ping error (DUP!)

Ntop is running on redhat. But It gives DUP! error while pinging to any places I dont know why DUP! error is occured. # ping google.com PING google.com (74.125.39.147) 56(84) bytes of data. 64 bytes from fx-in-f147.1e100.net (74.125.39.147): icmp_seq=1 ttl=44 time=54.1 ms 64 bytes from... (6 Replies)
Discussion started by: getrue
6 Replies

5. Shell Programming and Scripting

Identify duplicates and update the last 2 digits to 0 for both the Orig and Dup

Hi, I have a requirement where I have to identify duplicates from a file based on the first 6 chars (It is fixed width file of 12 chars length) and whenever a duplicate row is found, its original and duplicate row's last 2 chars should be updated to all 0's if they are not same. (I mean last 2... (3 Replies)
Discussion started by: farawaydsky
3 Replies

6. Shell Programming and Scripting

How to count dup records in file?

Hi Gurus, I need to count the duplicate records in file file abc abc def ghi ghi jkl I want to get below result: abc ,2 abc, 2 def ,1 ghi ,2 ghi, 2 jkl ,1 or abc ,2 def ,1 (3 Replies)
Discussion started by: ken6503
3 Replies

7. UNIX and Linux Applications

Deja-dup make my / full. So I cannot restore my back up

The problematic directory is the following: /root/.cache/deja-dup This directory grows until my "/" is full and then the restoring activity fails. I already tried to create a symbolic link with origin another partition where I have more space. However during the restoring activity ... (4 Replies)
Discussion started by: puertas12
4 Replies
MONGODB.COMMAND(3)							 1							MONGODB.COMMAND(3)

MongoDB::command - Execute a database command

SYNOPSIS
public array MongoDB::command (array $command, [array $options = array()], [string &$hash]) DESCRIPTION
Almost everything that is not a CRUD operation can be done with a database command. Need to know the database version? There's a command for that. Need to do aggregation? There's a command for that. Need to turn up logging? You get the idea. This method is identical to: <?php public function command($data) { return $this->selectCollection('$cmd')->findOne($data); } ?> PARAMETERS
o $command - The query to send. o $options - An array of options for the index creation. Currently available options include: o "socketTimeoutMS"This option specifies the time limit, in milliseconds, for socket communication. If the server does not respond within the timeout period, a MongoCursorTimeoutException will be thrown and there will be no way to determine if the server actually handled the write or not. A value of -1 may be specified to block indefinitely. The default value for MongoClient is 30000 (30 seconds). The following options are deprecated and should no longer be used: o "timeout"Deprecated alias for "socketTimeoutMS". o $hash - Set to the connection hash of the server that executed the command. When the command result is suitable for creating a MongoCom- mandCursor, the hash is intended to be passed to MongoCommandCursor.createFromDocument(3). The hash will also correspond to a connection returned from MongoClient.getConnections(3). CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 1.5.0 | | | | | | | Renamed the "timeout" option to "socketTime- | | | outMS". Emits E_DEPRECATED when "timeout" is | | | used. Added hash by-reference parameter. | | | | | 1.2.0 | | | | | | | Added options parameter with a single option: | | | "timeout". | | | | +--------+---------------------------------------------------+ RETURN VALUES
Returns database response. Every database response is always maximum one document, which means that the result of a database command can never exceed 16MB. The resulting document's structure depends on the command, but most results will have the ok field to indicate success or failure and results containing an array of each of the resulting documents. EXAMPLES
Example #1 MongoDB.command(3) "distinct" example Finding all of the distinct values for a key. <?php $people = $db->people; $people->insert(array("name" => "Joe", "age" => 4)); $people->insert(array("name" => "Sally", "age" => 22)); $people->insert(array("name" => "Dave", "age" => 22)); $people->insert(array("name" => "Molly", "age" => 87)); $ages = $db->command(array("distinct" => "people", "key" => "age")); foreach ($ages['values'] as $age) { echo "$age "; } ?> The above example will output something similar to: 22 87 Example #2 MongoDB.command(3) "distinct" example Finding all of the distinct values for a key, where the value is larger than or equal to 18. <?php $people = $db->people; $people->insert(array("name" => "Joe", "age" => 4)); $people->insert(array("name" => "Sally", "age" => 22)); $people->insert(array("name" => "Dave", "age" => 22)); $people->insert(array("name" => "Molly", "age" => 87)); $ages = $db->command( array( "distinct" => "people", "key" => "age", "query" => array("age" => array('$gte' => 18)) ) ); foreach ($ages['values'] as $age) { echo "$age "; } ?> The above example will output something similar to: 87 Example #3 MongoDB.command(3) MapReduce example Get all users with at least on "sale" event, and how many times each of these users has had a sale. <?php // sample event document $events->insert(array("user_id" => $id, "type" => $type, "time" => new MongoDate(), "desc" => $description)); // construct map and reduce functions $map = new MongoCode("function() { emit(this.user_id,1); }"); $reduce = new MongoCode("function(k, vals) { ". "var sum = 0;". "for (var i in vals) {". "sum += vals[i];". "}". "return sum; }"); $sales = $db->command(array( "mapreduce" => "events", "map" => $map, "reduce" => $reduce, "query" => array("type" => "sale"), "out" => array("merge" => "eventCounts"))); $users = $db->selectCollection($sales['result'])->find(); foreach ($users as $user) { echo "{$user['_id']} had {$user['value']} sale(s). "; } ?> The above example will output something similar to: User 49902cde5162504500b45c2c had 14 sale(s). User 4af467e4fd543cce7b0ea8e2 had 1 sale(s). Note Using MongoCode This example uses MongoCode, which can also take a scope argument. However, at the moment, MongoDB does not support using scopes in MapReduce. If you would like to use client-side variables in the MapReduce functions, you can add them to the global scope by using the optional scope field with the database command. See the MapReduce documentation for more informa- tion. Note The out argument Before 1.8.0, the out argument was optional. If you did not use it, MapReduce results would be written to a temporary col- lection, which would be deleted when your connection was closed. In 1.8.0+, the out argument is required. See the MapReduce documentation for more information. Example #4 MongoDB.command(3) "geoNear" example This example shows how to use the geoNear command. <?php $m = new MongoClient(); $d = $m->demo; $c = $d->poiConcat; $r = $d->command(array( 'geoNear' => "poiConcat", // Search in the poiConcat collection 'near' => array(-0.08, 51.48), // Search near 51.48oN, 0.08oE 'spherical' => true, // Enable spherical search 'num' => 5, // Maximum 5 returned documents )); print_r($r); ?> SEE ALSO
MongoCollection::aggregate, MongoCollection::findAndModify, MongoCollection::group. MongoDB core docs on database commands and on individual commands: findAndModify, getLastError, and repairDatabase (dozens more exist, there are merely a few examples). PHP Documentation Group MONGODB.COMMAND(3)
All times are GMT -4. The time now is 11:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy