0

when am running some deployment command in ruby script like

system('exam-deploy-all mod.rb >> temp.txt')

only part of output is getting stored in temp.txt file. I want to store whole output, I think its not storing because the output is very big. Can anyone tell me how to solve this problem?

1 Answer 1

1

I don't think you're losing output because there is too much, I'd guess that some of your output is going to the standard output stream (which you are saving in temp.txt) and some is going to the standard error (which you are not saving anywhere). You could try this:

system('exam-deploy-all mod.rb > temp.txt 2>errors.txt')

To put the output in temp.txt and the errors in errors.txt or one of these:

system('exam-deploy-all mod.rb > temp.txt 2>1')
system('exam-deploy-all mod.rb &> temp.txt')

to put them both in temp.txt.

Also, doing >> temp.txt appends the standard output to temp.txt without overwriting what is already there, > temp.txt will overwrite temp.txt with the new output.

All of this assumes that you're using something unixish (such as Linux or OSX) and that you system shell is Bourne-ish (such as bash).

You could also switch to Open3 if you want to handle all the I/O yourself rather than relying on system and temporary files. Using Open3 is more work but it may be worth it or maybe it isn't.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot friend... Its working, I was spending my time on this since 3 hrs. Thank you very much...:)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.