From help-octave-request at bevo dot che dot wisc dot edu Sat Oct 16 13:11:23 1999 Subject: dup2() on stdout [or using disp() on another file stream] From: Joao Cardoso To: help-octave Date: Sat, 16 Oct 1999 19:11:14 +0100 Hi, How can I use 'disp' on a file stream other than 'stdout'? 'disp' is an easy and nice way to print matrices, without the need to create a format string to use on 'fprintf'. I would like to: f_name = tmpnam fout = fopen(f_name,"w"); disp(fout, rand(3)) <--- not supporred fclose(fout) When I tried to use: f_name = tmpnam fout = fopen(f_name,"w"); old = fopen("old","w"); dup2(stdout, old); # save old stdout on 'old'? dup2(fout, stdout); # use new stdout disp(rand(3)) dup2(old, stdout); #revert to saved stdout? I wasn't able to revert stdout to the original stdout. what is wrong? I can't 'fclose(stdout)', either. Thanks, Joao -- Joao Cardoso | e-mail: jcardoso at inescn dot pt INESC, R. Jose Falcao 110 | tel: + 351 2 2094322 4050 Porto, Portugal | fax: + 351 2 2008487 --------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. To ensure that development continues, see www.che.wisc.edu/octave/giftform.html Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html ---------------------------------------------------------------------