I want to create a file, to save a list of fail2ban blocked ip addresses. So I thought I'd create a loop that will check with fail2ban every minute, and write the ip addresses to a file.
I used tee -a to append, not re-write the file every minute. Of course the problem with this approach is that ~/ips is filled with duplicates every minute.
Is there a way to tell tee not to write an ip address in the file, if it already exists? Of course there's a good chance my whole approach is completely wrong, so I'm open to suggestions.
Hi Gurus,
I had a question regarding avoiding duplicates.i have a file abc.txt
abc.txt
-------
READER_1_1_1> HIER_28056 XML Reader: Error occurred while parsing:; line number ; column number
READER_1_3_1> Sun Mar 23 23:52:48 2008
READER_1_3_1> HIER_28056 XML Reader: Error occurred while... (7 Replies)
Hi all.
I want to check the free space on a given FS and process the output. Right now, I'm using a temp file to avoid using df twice. This is what I'm doing
#!/usr/bin/ksh
...
df -k $FS_NAME > $TMP_FILE 2>&1
if ]; then
RESULT="CRITICAL - $(cat $TMP_FILE)"
else
cat $TMP_FILE | ...... (3 Replies)
Good afternoon.
I am a newbie.
We just had a potentially big problem (negated to having good backups).
Basically, there is an option in SAM, to delete all the data from the system that a user ever created.
Lo and behold, silly me, I choose that option, and all sorts of needed files... (5 Replies)
Guys
following lines help me in getting numbers from PID column ,to be thrown into first column of a CSV file.
COLUMNS=2047 /usr/bin/ps -eo pid,ppid,uid,user,args | grep -v "PID" > /tmp/masterPID.txt
cat /tmp/masterPID.txt|while read line
do
PID=`echo $line|awk '{print $1}'`
echo "$PID"... (4 Replies)
Hi Everyone,
# cat a.txt
94,aqqc,62345907,
5,aeec,77,
# cat 1.pl
#!/usr/bin/perl
use strict;
use warnings;
use Date::Manip;
open(my $FA, "/root/a.txt") or die "$!";
while(<$FA>) {
chomp;
my @tmp=split(/\,/, $_);
if (index($tmp, "qq") ne -1) {
... (4 Replies)
Hi alll
I have a file with following kind input
I want in output duplicates should not be there but there should be numbering mentioned before that like (4 Replies)
Hi all
I have a file with following input
It contains 5 columns
gene name drug drug ID disease approved
Now the same gene is repeated many times with different data in column2,3 ,4,5
I want to arrange dat in such a way that there shuld be one entry in the column(no... (2 Replies)
Hello,
I am trying to run some code on Matlab over ssh . The code takes around 5-6 hours to complete. so after giving the command to run it , I locked my machine and then went off to sleep at night, only to discover in the morning that I get this message :
...Code running, partial results... (1 Reply)
Hello,
I have been working on script in which search and replace the multiple pattern.
1. update_params.sh read the multiple pattern from input file ParamMapping.txt(old_entry|New_entry) and passing this values one by one to change_text.sh
2. change_text.sh read... (0 Replies)
Discussion started by: ketanraut
0 Replies
LEARN ABOUT PHP
mongodbref
MONGODBREF(3) 1 MONGODBREF(3)The MongoDBRef classINTRODUCTION
This class can be used to create lightweight links between objects in different collections.
Motivation: Suppose we need to refer to a document in another collection. The easiest way is to create a field in the current document. For
example, if we had a "people" collection and an "addresses" collection, we might want to create a link between each person document and an
address document:
Example #1
Linking documents
<?php
$people = $db->people;
$addresses = $db->addresses;
$myAddress = array("line 1" => "123 Main Street",
"line 2" => null,
"city" => "Springfield",
"state" => "Vermont",
"country" => "USA");
// save the address
$addresses->insert($myAddress);
// save a person with a reference to the address
$me = array("name" => "Fred", "address" => $myAddress['_id']);
$people->insert($me);
?>
Then, later on, we can find the person's address by querying the "addresses" collection with the MongoId we saved in the "people" collec-
tion.
Suppose now that we have a more general case, where we don't know which collection (or even which database) contains the referenced docu-
ment. MongoDBRef is a good choice for this case, as it is a common format that all of the drivers and the database understand.
If each person had a list of things they liked which could come from multiple collections, such as "hobbies", "sports", "books", etc., we
could use MongoDBRefs to keep track of what "like" went with what collection:
Example #2
Creating MongoDBRef links
<?php
$people = $db->selectCollection("people");
// model trains are in the "hobbies" collection
$trainRef = MongoDBRef::create("hobbies", $modelTrains['_id']);
// soccer is in the "sports" collection
$soccerRef = MongoDBRef::create("sports", $soccer['_id']);
// now we'll know what collections the items in the "likes" array came from when
// we retrieve this document
$people->insert(array("name" => "Fred", "likes" => array($trainRef, $soccerRef)));
?>
Database references can be thought of as hyperlinks: they give the unique address of another document, but they do not load it or automat-
ically follow the link/reference.
A database reference is just a normal associative array, not an instance of MongoDBRef, so this class is a little different than the other
data type classes. This class contains exclusively static methods for manipulating database references.
CLASS SYNOPSIS
MongoDBRef
MongoDBRef
Methods
o publicstatic array MongoDBRef::create (string $collection, mixed $id, [string $database])
o publicstatic array MongoDBRef::get (MongoDB $db, array $ref)
o publicstatic bool MongoDBRef::isRef (mixed $ref)
SEE ALSO
MongoDB core docs on databases references.
PHP Documentation Group MONGODBREF(3)