OSSubprocess
OSSubprocess copied to clipboard
Calling mongo cli only returns a few lines of the output
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