in reply to interacting with background shell
The reason I mention it, is that matlab(which I don't use, so this is speculation) may act funny in interactive mode, unless it is running from a shell. So if#!/usr/bin/perl use warnings; use strict; use IPC::Open3; $|=1; #my $pid=open3(\*IN,\*OUT,\*ERR,'/bin/bash'); my $pid=open3(\*IN,\*OUT,0,'/bin/bash'); # set \*ERR to 0 to send STDERR to STDOUT my $cmd = 'matlab -interactive'; #send cmd to bash print IN "$cmd\n"; #getresult my $result = <OUT>; print $result;
dosn't seem to work well, try the above trick.my $pid=open3(\*IN,\*OUT,0, '/usr/bin/matlab');
Another thing I will mention, is that if you are doing huge number calculations, you may run into a problem with the 4k buffer that IPC uses on linux. In case you are curious, see what I did for running the 'bc' calculator, and getting huge output at IPC3 buffer limit problem
|
|---|