LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 01-29-2010, 05:16 PM   #1
BrianK
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:

Code:
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, 06:50 PM   #2
BrianK
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, 11:53 AM   #3
ta0kira
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:
Code:
% prepended to the script:
script_out = fopen('/proc/self/fd/3', 'a');
When running the script:
Code:
matlab (some stuff to trick it into running a script) 3>&1 1>&2
In the body of the script:
Code:
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
 
  


Reply


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 10:00 AM
stdout,stderr makes program crash surfchen Linux - Newbie 3 03-11-2008 05:27 AM
Python: catch stdout and stderr from external command Ephracis Programming 9 02-28-2008 08:57 AM
redirecting stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 02:36 AM
Reopen the stdout and stderr rahul_kulkarni Programming 3 02-21-2005 06:55 AM


All times are GMT -5. The time now is 02:00 PM.

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