Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling mongo cli only returns a few lines of the output #74

Open
jmari opened this issue Nov 27, 2022 · 0 comments
Open

Calling mongo cli only returns a few lines of the output #74

jmari opened this issue Nov 27, 2022 · 0 comments

Comments

@jmari
Copy link

jmari commented Nov 27, 2022

I'm trying to get the output from mongo cli. While it works using LibC call, I'm not able to make it works on OSSubprocess. I need it working on OSSubprocess because LibC call blocks the image process until the child finish his job...so on libc my code is:

buildCommand
...
^ (self pathToMongoExecutable ,'mongo --eval ''' ,
		'DBQuery.shellBatchSize = ', limit asString,';', 
		'db.getCollection("', self collection  ,'")', '.aggregate(',
		queryString contents , ');'' ',
		self database,
		' 1>' , self outFilename)
....
result :=LibC runCommand: self buildCommand.

And on OSSubprocess (I've tried all of the options described in Readme file)...

totalStdout := String new writeStream.
	OSSUnixSubprocess new
					command: self pathToMongoExecutable ,'mongo';
					arguments: {	'--eval'. 
						'''DBQuery.shellBatchSize = ', limit asString,';', 
						'db.getCollection("', self collection  ,'")', 
							'.aggregate(', self buildQuery, ');'''.
						self database.};
		redirectStdout;
		redirectStderr;
		runAndWaitPollingEvery: (Delay forMilliseconds: 500)
	doing: [ :process :outStream :errStream |  
		| read |
		read := outStream upToEnd.
		"Next 2 lines is to simply update the Playground"
		totalStdout nextPutAll: read.
		errStream upToEnd.
	]
	onExitDo: [ :process :outStream :errStream  |
		(Delay forMilliseconds:5000) wait. 
		process closeAndCleanStreams.
		Transcript show: 'Total stdout: ', totalStdout contents.
	]

The output of my code using OSSp is

MongoDB shell version v4.0.3
connecting to: mongodb://127.0.0.1:27017/finhava
Implicit session: session { "id" : UUID("3a7496c6-bddf-4c04-9083-42a5782dc91b") }
MongoDB server version: 4.0.3
DBQuery.shellBatchSize = 5000;db.getCollection("TFVottunUploadedActivity").aggregate([{$match:{"product_step":1,"workflow":"00 Descarga FORM"}}]);

It finish here, using LibC I get the result after, any help will be welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant