1

I want to get the output from a program in Linux, and I put this into a .sh file:

wine Blockland.exe ptlaaxobimwroe -dedicated -port 30100 > consoleLog.txt

It executed the program, but created a blank file. This command always works when directly executed in a Terminal window. So why isn't it printing the output to the file when in a .sh script?

2
  • You are running a DOS console application, which does not necessarily write to stdout or stderr, but it writes to the "console". It's nearly impossible to capture the "console" output reliably. The only tool that I have ever seen that is able to capture console output is expect by Don Libes, and that does all sorts of hacks. Commented Jul 25, 2013 at 19:52
  • Or try executing in a script session. Commented Jul 25, 2013 at 20:03

2 Answers 2

1

Possibly because it prints its output to the stderr stream, not to stdout. Try appending 2>&1 to the end of command (after consoleLog.txt), or just use &> instead of >.

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

Comments

0

redirect stdout with exec:

#!/bin/sh
#Example script
exec > consoleLog.txt
wine Blockland.exe ptlaaxobimwroe -dedicated -port 30100

Comments

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.