Sponsored Content
Top Forums UNIX for Beginners Questions & Answers UNIX Shell Script to Remove MongoDB Document-Based on Many inputs Post 303042582 by senthilmadhanT on Tuesday 31st of December 2019 12:15:52 AM
Old 12-31-2019
UNIX Shell Script to Remove MongoDB Document-Based on Many inputs

Here I am in a position to write a Unix Shell script(.sh) to remove MongoDB collection documents. I know how to remove based on a condition like below and it works for me.

Code:
eval 'db.Collection.remove({TimeStamp:{$lte: "'$var'"}})

But I need to change the remove statement based on a new parameter ,lets say PID which will receive bunch of inputs(Many PID's).

I don't need to remove the collection based on the Timestamp field ,Instead my condition has to be changed as per my previous statement.

I went through many forums ,But I am not able to get the solution.

Please help me to resolve this in my UNIX shell script.
Sample Data:-
Code:
 {"TimeStamp": "20191230", "PID": 1233} 
{"TimeStamp": "20191226", "PID": 1456} 
{"TimeStamp": "20191225", "PID": 4566} 
{"TimeStamp": "20191226", "PID": 8987}

My Collection have an attribute called PID as shown above ,like Timestamp.Where we will store integer kind of values like 1233,1456,4566..etc .So I require to remove documents who has PID as 1233,1456 in my batch dynamically

Last edited by senthilmadhanT; 12-31-2019 at 01:32 AM..
 

10 More Discussions You Might Find Interesting

1. Programming

UNIX Shell Script to Create a Document of a PLSQL code.

Hi All, I am supposed to present the documentation for the PLSQL code (PACKAGES, PROCEDURE, FUNCTIONS) of my application. There are sufficient comments in my code. Has anyone written any Shell Script Utility which can parse the PLSQL code and generate some kind of document ( preferrably HTML not... (1 Reply)
Discussion started by: gauravsachan
1 Replies

2. Shell Programming and Scripting

passing argument to shell script that reads user inputs

Hi, Lets say I have a script "ss" which does this read abc echo $abc read pqr echo $pqr Now if I want to pass and argument to only "abc" how do I do it. If I do echo "somevalue" | ss, it does not prompt for pqr and its value comes out as blank. Any help is appreciated Thanks P (6 Replies)
Discussion started by: patjones
6 Replies

3. Shell Programming and Scripting

Need inputs on UNIX script basics

Hi UNIX Gurus, I have a SQL utility which fires DML statements against DB2 tables. Logic is to identify DML statements, put it into a file ($dml) and execute the job. DML file can have more than 1 DML statements....but all of 1 type at a time.....either all UPDATE or all DELETE. Job first... (2 Replies)
Discussion started by: ustechie
2 Replies

4. Shell Programming and Scripting

Perl script for taking inputs from one script and storing them into a document.

Hi. I wanted to create a Perl script which can take the outputs of a Perl script as it's input and temporarily store them in a document. Need help. Thanks.:) (8 Replies)
Discussion started by: xtatic
8 Replies

5. Shell Programming and Scripting

Need a shell script which takes two inputs and copy the files from one directory to other

Hi, I am using solari 10 OS which is having bash shell. I need a shell script which takes user home directory and name of the file or directory as a input and based on that copy the files accordingly to the other directory. example:I hava a machine1 which is having some files in a... (8 Replies)
Discussion started by: muraliinfy04
8 Replies

6. Shell Programming and Scripting

Script which takes two inputs based on that execute othe scripts

Hi, I am using solaris 10 bash shell.this might a small script but i am not much familiar with scripting. My requirement here is script should prompt for users two opions like this "please select either any one option makefile or make& build file". if the user selects make file option... (2 Replies)
Discussion started by: muraliinfy04
2 Replies

7. UNIX for Dummies Questions & Answers

How to give multiple inputs to a shell script

Got struck while trying to write a shell script which should automatically give input. While running a script for eg: (adpatch.sh) It Prompts for Multiple inputs like: Do you currently have files used for installing or upgrading the database installed in this APPL_TOP ? need to give... (2 Replies)
Discussion started by: abdmoha
2 Replies

8. UNIX for Dummies Questions & Answers

How to send keyboard inputs toa UNIX command executed from a shell script?

I have a unix command that prompts for 'y'. How do I run this from my shell script? (4 Replies)
Discussion started by: Sree10
4 Replies

9. Shell Programming and Scripting

HERE Document in Shell Script

Hi, I have a shell script to install one of our products. It comprises of commands that are specific to the product installation. These commands require user inputs at different stages. To avoid manual feeding of inputs every time, I tried using HERE document. it is like- #! /usr/bin ... (1 Reply)
Discussion started by: nishant.kansal@
1 Replies

10. Shell Programming and Scripting

Shell script inputs to python

Hi I am trying to pass 2 input parameters from shell script to python API end point ,but not passing what i expected when print those inputs .Please advise data.txt " 7554317" ,xx5e1 " 7554317" ,xx96 " 7554317" ,xxd6 " 554317" ,xde cat $sites/data.txt |sort |uniq >$sites/a.txt... (5 Replies)
Discussion started by: akil
5 Replies
CHUDREMOTECTRL(1)					      General Commands Manual						 CHUDREMOTECTRL(1)

NAME
chudRemoteCtrl - start or stop the collection of performance monitor data in a performance monitor remote server application. SYNOPSIS
chudRemoteCtrl [ -m ] [ executable [args... ] ] chudRemoteCtrl -s label chudRemoteCtrl -e chudRemoteCtrl -k PID DESCRIPTION
chudRemoteCtrl is a command line tool that allows for the collection of performance data by any active performance monitor remote server application. There are currently two CHUD Tools that can be put in remote performance monitor server mode: MONster, and Shark (as well as their command line counterparts). Typically, chudRemoteCtrl is invoked on the command line or in a shell script, followed by the path to an executable to be measured and its arguments. chudRemoteCtrl issues a chudStartRemotePerfMonitor message immediately after launching the specified target program. When the launched program terminates, chudRemoteCtrl issues a chudStopRemotePerfMonitor message, and then exits. When the '-s', '-e' or '-k PID' options are used, no program is launched. OPTIONS
-r seconds: If the 'chudStartRemotePerfMonitor' message fails to either acquire or start the remote monitoring service, then keep try- ing to start again, until the specified number of seconds has elapsed. The same thing is true of the '-e' option. If there is a '-r <seconds>' argument on the command line, and a failure occurs trying to stop the remote profiling program, the stop message will be sent again until the retry time limit is reached. -s label: Issue a chudStartRemotePerfMonitor message with the specified label and exit. A 'label' is a string of up to 32 characters. -e Issue a chudStopRemotePerfMonitor message and exit. -q silence some of the non-essential warning and error output. -kPID Send a UNIX signal (SIGUSR1 to start profiling, SIGUSR2 to stop profiling) to the specified process-id. For example, if a command- line profiling tool, is running as PID 4267, using '-k 4267' along with a '-s' will send a SIGUSR1 to the command-line profiling tool and it will start sampling, while '-k 4267' along with a '-e' will send a SIGUSR2 to the command-line profiling tool and it will stop sampling. A 'start' example: % chudRemoteCtrl -s session_42 -k 4267. And a 'stop' example: % chudRemoteCtrl -e -k 4267. The command-line CHUD tool 'shark' responds to UNIX signals and toggles performance profiling. You can repeatedly send '-s <label> -k <PID#>' to shark and it will toggle profiling start or stop. Sending '-e -k <PID#>' to shark will stop sampling (if it's run- ning) and cause shark to EXIT. -m Set the performance monitor mark bit in the main thread of the launched child process. DIAGNOSTICS
chudRemoteCtrl returns a zero (0) upon success and a non-zero value on failure. BUGS
Please send your comments, suggestions and bug reports to: perftools-feedback@group.apple.com SEE ALSO
monster(1), shark(1) CHUD
6 October 2003 CHUDREMOTECTRL(1)
All times are GMT -4. The time now is 01:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy