1

In qsub Oracle Grid Engine, this redirects the output to a file out.txt,

qsub -o $(pwd)/out.txt -sync y awesome_script.sh

How to redirect the output to stdout ?

elm
  • 20,117
  • 14
  • 67
  • 113

1 Answers1

4

You can specify /dev/stdout as the filename.

qsub -o /dev/stdout -sync y awesome_script.sh

More info can be found in this answer: https://unix.stackexchange.com/questions/36403


Edit:

A common Unix idiom is that the filename - means stdin for an input file and stdout for an output file. This has to be explicitly handled by the program, though; it's not automatic. I can't find anything saying whether qsub uses this idiom. Try it, it might work.

If you want to pipe the output to another command that does something with it, you could create a named pipe (man mkfifo) and send the output to that, with the other process reading from the pipe. Start the read process first.

For another idea, see this answer, which explains how to use bash process substitution. I haven't used this much, but I think it would be something like:

qsub -o >(other-command-or-pipeline) -sync y awesome_script.sh

If you simply want to see the output in real-time, you could specify /dev/tty as the file. Or, you could output to a file and watch it with tail -f.

Hope one of these ideas works for you.

Community
  • 1
  • 1
Tom Zych
  • 13,329
  • 9
  • 36
  • 53
  • Many Thanks for your response. It seems this approach does not function with `qsub` though. – elm Feb 24 '16 at 11:35
  • @elm: How is it failing? Is `/dev/stdout` not there? How about `/dev/fd`? What OS? – Tom Zych Feb 25 '16 at 01:11
  • Program somehow stalls, no cpu loads, no I/O, no files transformed. Using Centos 6. May the issue be at redirecting remote `/dev/stdout` to master `/dev/stdout` ? – elm Feb 25 '16 at 10:00
  • Any help appreciated. +1 for devising proposed solution which works in most cases. – elm Feb 25 '16 at 10:02
  • Hi @elm, looks like some of that was useful. Since other people may encounter a similar problem, please consider editing your question or leaving a comment, to let them know which approach worked best for you. – Tom Zych Feb 25 '16 at 23:00
  • Best approach that did work for the use case included `tail -f`. – elm Mar 02 '16 at 07:11