简体   繁体   中英

Linux: No output from a program in a .sh script

I am trying to execute a Windows program in Linux, and I want to get the output (stdout) from that process. I put this text into a .sh file: wine Blockland.exe ptlaaxobimwroe -dedicated -port 30000 >> 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?

It could be sending output to stderr. To account for this possibility, try

wine Blockland.exe ptlaaxobimwroe -dedicated -port 30000 2>&1 >>consoleLog.txt

The 2>&1 bit redirects stderr (file descriptor 2) to stdout (file descriptor 1). Then it redirects stdout (which includes stderr output now) to your log file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM