[SERVER-6567] is it possible to shell out to the OS from the mongo shell? Created: 23/Jul/12  Updated: 15/Aug/12  Resolved: 23/Jul/12

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: 2.0.4
Fix Version/s: None

Type: Question Priority: Minor - P4
Reporter: George Nikopoulos Assignee: Scott Hernandez (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux red hat 5.6


Participants:

 Description   

Using the mongo shell as admin, but finding it anoying to heave to shell out of the mongo shell, ino the OS, and then back in and go through the authentication again. Is there any command similar to ( ! or "host" in sqlplus from oracle) to allow for this? Thank you



 Comments   
Comment by Scott Hernandez (Inactive) [ 23/Jul/12 ]

Yes:

> run("ls", "-l")
Mon Jul 23 17:31:56 shell: started program ls -l
sh27660| total 2955568
...

BTW. ctrl-z was broken in 2.0.x

Comment by George Nikopoulos [ 23/Jul/12 ]

thank you, it works. One more request on this topic. Is it possible to pass a parameter to the command? ex: run("ls") works fine, but I am getting those erorrs : "shell: started program ls -ltr
sh32410| Unable to start program ls -ltr errno:2 No such file or directory
255", when I do run("ls -ltr").

Comment by Scott Hernandez (Inactive) [ 23/Jul/12 ]

Yes, there is a run("path/to/executable") function which shells out:

> run("ls")
Mon Jul 23 16:14:41 shell: started program ls
sh26218| Desktop
sh26218| Documents
sh26218| Downloads

As you can see, this will just run a command. There is no way to go to get the output nor to have an interactive os shell/prompt.

You can use normal shell stuff like pressing Ctrl-Z to pause and "fg" to resume for example on linux.

Generated at Thu Feb 08 03:12:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.