MongoDB commands in linux console with --eval (print - arrays

I try run command mongo in linux console without entering into mongo shell.
To do it:
[root#router-mongos ~]# mongo --eval " printjson(show databases)"
But not run, this is the output:
MongoDB shell version: 2.6.10
connecting to: test
2015-06-10T18:33:39.834+0200 SyntaxError: Unexpected identifier
Though if you are uses:
[root#router-mongos ~]# mongo maria --eval " printjson (db.stats())"
o
mongo --eval " printjson(db.adminCommand('listDatabases'))"
Yes, the output is the same if you run it in shell.
Has anyone ever used this? can we help me? Thanks.

From the Mongo Shell documentation:
You cannot use any shell helper (e.g. use , show dbs, etc.) inside the JavaScript file because they are not valid JavaScript.
Following that, there is a table showing the JavaScript equivalents of the various shell helpers. From that, show dbs and show databases should be replaced by db.adminCommand('listDatabases') in your Mongo shell scripts.

Related

mongo is not recognized as internal or external command

inspite of installing mongodb ,my mongo command showing that "mongo isn't recognizable as internal or external command"
though i have set the path variable mongod and mongosh is working but when I m trying to go for mongo then it hasn't happening

Sqlite> not showing up in Git Bash terminal

Where is the sqlite> tag on Git Bash so I know when I'm accessing sqlite? There's also no version text too.
When I enter .quit into git bash it quits out of sqlite (showing that I am accessing sqlite) but there's no tag like there is in cmd or powershell
On the cmd terminal when I access Sqlite3 it clearly shows sqlite> so I know when I'm in it.
How do I get the sqlite> tag on Git Bash?
Things like these make use of interactive terminals, and MinTTY (the underlying emulator used to run Git Bash) doesn't get along well with them. You need to prefix every such command with winpty. In this case: winpty sqlite3.

How to run C program in Netbeans

I am trying to run the dmtx project from Git (link: https://github.com/dmtx/dmtx-utils) in Netbeans. I have configured the Project Properties in NetBeans and the project is building correctly.
When I run a particular C file (dmtxwrite.c) through bash it gives the correct output. As mentioned in the README, the correct way to run it in Bash is:
$ echo -n 123456 | dmtxwrite > image.png.
Now my question is how can I do the same using NetBeans?
Till now I only found answers related to passing command line arguments. However, that does not work.
how can I do the same using NetBeans?
Select your C project in the Projects panel.
Right-click it to open the context menu, then select Properties > Run > Run Command.
Enter your command to be run in the Run Command field.
This is the Help for Run Command in NetBeans 8.2:
Enter a command to be executed when you run the project. The IDE runs the command as /bin/sh -c "run-command" which enables you to use any shell syntax including redirection and pipes. Type the command in the Run Command field the same way you would run it from the command line. For example, you could type my-script -opt1 -opt2 to run a script and specify two options, or mycommand > output.log to run your command and send the output to a logfile. The Run Command list maintains history of previous entries so you can go back to the default value or select among several different commands you have entered.

SOLR full-import not working when running using lynx command

I want to setup a cron in Amazon EC2 Linux to run a SOLR full-import at 12:15AM every night.
Before I setup the cron I tried testing in the terminal whether it is working or not. I used below command to test
/usr/bin/lynx http://amzon-instance-ip:8983/solr/work/dataimport?command=full-import
Output of the command:
[1] 15153
But when I go to below url to check whether the full-import actully initiated. I see the full-import command is not running.
http://amzon-instance-ip:8983/solr/#/workb/dataimport//dataimport
Anyone can help me why the SOLR full-import not running with lynx command? Am I using lynx correctly or do I need to use a differnt approach? Any Suggestions please.
I spent some time on internet searching the solution for why a url not working with lynx but could not find the solution.
Thanks for #Oyeme suggestion, I got two ways to get my URL running using linux curl and wget commands.
Using linux curl command:
curl -s ' http://amzon-instance-ip:8983/solr/work/dataimport?command=full-import&clean=false' > /dev/null
Using linux wget command:
wget -O /dev/null ' http://amzon-instance-ip:8983/solr/work/dataimport?command=full-import&clean=false'

On Linux CentOS 7 OS how schedule jobs to run drush to re-index solr, run cron and clear cache for drupal 7 sites

HI a newbie to server management... We need to automate hourly script to run drush to re-index solr, run cron and clear cache on multiple servers. I'm sure there has to be .bat file or something?
At first: You have no '.bat' files in any unix system (but ofcourse you can write scripts named something.bat, but nothing special happens ;-)).
You need to have drush installed somewhere in your sytem. I use to install it in /usr/local/share/drush and put a link from /usr/local/share/drush/drushto /usr/local/bin/drush. Then run crontab -e to edit the schedule. An editor is launched inside your console window. If it shows an empty window or the file contains only lines starting with "#", then put
MAILTO=your.mail#example.com
PATH=/usr/local/bin:/bin:/usr/bin:$HOME/bin
#daily drush #live -q -y cron > /dev/null
In this case drush cron is executed daily for a drupal installation with a site-alias #live. The output is sent to /dev/null, so that I do not get any error messages.
PS: Get familiar with the cron systems and the crontab command as well as shell scripting. They are unix' standard tools and are needed for those kind of tasks.
PS2: You also want to know the concept of drush site-aliases. Run drush topic docs-aliases to learn more about it.

Resources