Sponsored Content
Top Forums Shell Programming and Scripting Running a command in another cli Post 302995332 by Junaid Subhani on Tuesday 4th of April 2017 03:31:57 PM
Old 04-04-2017
Running a command in another cli

I am writing a script to login to to a mongo DB node and get the status of that machine. The usual work flow is :

Code:
[root@mongodb-secondary-1 ~]# mongo admin -u root -p root 
MongoDB shell version: 3.0.11
connecting to: admin
rs0:SECONDARY>

Then in the new prompt I can run a command to check status :


Code:
rs0:SECONDARY> rs.status()
{
	"set" : "rs0",
	"date" : ISODate("2017-04-04T19:24:56.369Z"),
	"myState" : 2,
	"syncingTo" : "172.29.219.108:27017",
	"members" : [
		{
			"_id" : 0,
			"name" : "172.29.219.108:27017",
.
.
.

Now since I am loging into from another node, I want this all in one shot. Something like :

Code:
mongo admin -u root -p root ; rs.status()

But unfortunately this does not work. Any idea how I can send a command to another application CLI and get the status ?

---------- Post updated at 12:31 AM ---------- Previous update was at 12:26 AM ----------

Got the solution :

Code:
mongo admin -u root -p root --quiet --eval 'printjson(rs.status())'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

running command more than twice in one second?

how do i do that? say i wanna run a check script but i want it to run at least twice in one second, what kinda script would that need? matter, this on a sunsolaris system. i would like it to run as many times as possible under one second but i guess i can live with 2 so does anyone know... (4 Replies)
Discussion started by: Terrible
4 Replies

2. SuSE

inconsistent ls command display at the command prompt & running as a cron job

Sir, I using the following commands in a file (part of a bigger script): #!/bin/bash cd /opt/oracle/bin ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out If I run this from the command prompt the result is: 2007-05-16 if I run it as a cron job then... (5 Replies)
Discussion started by: rajranibl
5 Replies

3. UNIX for Dummies Questions & Answers

Running set options from the command line and bash command

I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing set you can also use them "on the command line when running a script..." and it lists this in a small table: set -o option Command Line... (5 Replies)
Discussion started by: Straitsfan
5 Replies

4. Linux

Way to execute a command from CLI

OS : Linux Kernel ver : 2.6x Is there any legit difference between way that shell interprets the below mentioned command lines in Linux environment? Option A> . <exec_file_name> arg1 agr2 Option B> ./<exec_file_name> arg1 agr2 The reason for me asking this silly question is... (2 Replies)
Discussion started by: kumarjt
2 Replies

5. Shell Programming and Scripting

Command to check only Autosys running jobs with autorep like command

Hi, Is there any specific command to use to check only say Running jobs via autorep or similar command for Autosys? (0 Replies)
Discussion started by: sidnow
0 Replies

6. AIX

Command to see the status of managed node from CLI of HMC?

Folks, Asking a silly question - is there a way to know the status(Power Off/Running) of a managed node from CLI of HMC, alike the way we see it for the LPARs running on the node from 'vtmenu'? Most of us use the UI to see the status of the LPARs/Managed node - but just inquisitive to know if... (4 Replies)
Discussion started by: thisissouvik
4 Replies

7. UNIX for Dummies Questions & Answers

Conversion program/command via CLI

I already know about the docx2txt program, and it's extremely helpful. ssconvert is also really helpful, but unlike docx2txt, it works both ways. How does one convert a .txt file to .docx via CLI, or is it even possible?? This: docx2txt example.docx results in making a .txt file out of... (2 Replies)
Discussion started by: Huitzilopochtli
2 Replies

8. AIX

I'm facing problem with rpm command, when running the command and appears this error:

exec(): 0509-036 Cannot load program /usr/opt/freeware/bin/rpm because of the following errors: 0509-022 Cannot load module /opt/freeware/lib/libintl.a(libintl.so.1). 0509-150 Dependent module /opt/freeware/lib/libiconv.a(shr4.o) could not be loaded. 0509-152 Member... (4 Replies)
Discussion started by: Ohmkar
4 Replies

9. UNIX for Beginners Questions & Answers

Another one line command where I'd like to determine if Ubuntu or Red Hat when running command

Hello Forum, I'm making very good progress on my report thanks to the very helpful people on this forum. I've been able to successfully create my report for my Red Hat servers. But I do have a few ubuntu servers in the mix and I'd like to capture some data from them when an ssh connection is... (8 Replies)
Discussion started by: greavette
8 Replies

10. Programming

Arduino-cli - Uploading to Unknown Chinese Arduino Boards using the Arduino Command Line Interface

In my further exploration of Arduino, today I decided to install the arduino-cli on my mac today. https://github.com/arduino/arduino-cli I followed the instructions for macOS but when I got to this part: arduino-cli board list I got the dreaded "Unknown" Fully Qualified Board Name... (1 Reply)
Discussion started by: Neo
1 Replies
wicd-cli(8)						      System Manager's Manual						       wicd-cli(8)

NAME
wicd-cli - command-line interface to wicd SYNOPSIS
wicd-cli [options] DESCRIPTION
This manual page documents briefly the wicd-cli command. wicd-cli is a scriptable command-line only "client" for wicd. OPTIONS
-h, --help Show summary of options. -n network-id, --network=network-id Specify which network wicd-cli should act on. -p property, --network-property=property Show property from network details. -s value, --set-to=value Set selected property to value -m name, --name=name Set the name for the profile to load/save to name. -S, --scan Scan available wireless networks. -w, --save Save the network connection profile. -l, --list-networks List the networks WICD has in its cache. -d, --network-details Show details of selected network. -x, --disconnect Disconnect from the current network. -c, --connect Connect to the selected network. -e, --list-encryption-types View the available encryption templates WICD can use. -y, --wireless Use the wireless interface. -z, --wired Use the wired interface. -o, --load-profile Load a wired connection profile. SEE ALSO
wicd(1), wicd-client(1), wicd-gtk(8), wicd-curses(8) AUTHOR
wicd-cli was written by Ronuk Raval. This manual page was written by David Paleino <dapal@debian.org>, for the Debian project (and may be used by others). Dec 2009 wicd-cli(8)
All times are GMT -4. The time now is 05:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy