Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-29-2010, 06:16 PM   #1
Senior Member
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Can't seem to catch some output from a program - not stdout or stderr. uhh.. help?

The program in question in Maya (by Autodesk).

I'm running a little test mel script that looks like so:

print "MEL -- PRINT CALL\n";
python("print 'PYTHON -- PRINT CALL. FROM MEL'");
when I run this little script from the command line (through maya), I see both print statements. However, if I try to redirect stdout and/or stderr to a file, I only get the first line via stderr & never see the second line. I'm doing my redirection like so:

maya -batch -script my_script 2> err
maya -batch -script my_script 1> out

Doing it that way, I see the first line in 'err' but don't see second in either.

Is there a way I can see how the second line is being printed?
Old 01-29-2010, 07:50 PM   #2
Senior Member
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
hmm... found that maya is stealing stdout & stderr, and doing it's own thing with them. Not sure if I can do what I'm after at all.

If anyone knows, feel free to post, otherwise, I'm calling it quits on this one.
Old 01-30-2010, 12:53 PM   #3
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
I ran into something similar to this with MATLAB, where MATLAB would run over both 1 and 2 with whatever it felt like, so I wrote a wrapper that inserted a MATLAB command to open /proc/self/fd/3, then redirected 3 on the command-line. I gave it a name like script_out, and in the script I sent output there instead of standard output. This isn't MEL, but it should be obvious the correlation:
% prepended to the script:
script_out = fopen('/proc/self/fd/3', 'a');
When running the script:
matlab (some stuff to trick it into running a script) 3>&1 1>&2
In the body of the script:
fprintf(script_out, '%s\n', row_data(1:length(row_data)-1));
MATLAB doesn't recognize pre-opened file descriptors other than 1 and 2, but maybe Maya will let you use 3 without going through /proc.
Kevin Barry


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
stderr vs stdout sniffer_raghav Programming 2 09-05-2008 11:00 AM
stdout,stderr makes program crash surfchen Linux - Newbie 3 03-11-2008 06:27 AM
Python: catch stdout and stderr from external command Ephracis Programming 9 02-28-2008 09:57 AM
redirecting stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 03:36 AM
Reopen the stdout and stderr rahul_kulkarni Programming 3 02-21-2005 07:55 AM

All times are GMT -5. The time now is 11:27 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration