Message Boards Message Boards

0
|
4615 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Bug: math -script file doesn't work when stdout redirected

Posted 10 years ago
Here is a sample session illustrating the problem. The file "test.m" just contains "a=b; Print".
$ math -noprompt -script test.m
b
$ math -noprompt -script test.m > out
$ cat out
$ ls -l out-rw-rw-r-- 1 tigran tigran 0 May 28 14:27 out

As you can see, if I do NOT redirect the output then the script works fine, i.e. "b" (which is the value of a) is printed to the terminal. But when the output is redirected to a file, nothing is printed, i.e. the file is empty (zero size as shown by ls -l output).

I have found a workaround for this problem: namely, if instead of '-script file' option I pass -run "<<file" then it works as expected:
$ math -noprompt -run "<<test.m" > out
$ cat out
b
Btw, if I want to see the output on the terminal, then I would have to redirect the input to /dev/null, just as I suspected:
$ math -noprompt -run "<<test.m" < /dev/null
b

otherwise it would display the prompt (ignoring -noprompt option) and expect interactive input. But this is ok, i.e. it is a reasonable behaviour.
POSTED BY: Tigran Aivazian
Sorry about the mess in my post --- I wasn't sure how to insert the text verbatim...
POSTED BY: Tigran Aivazian
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract