I was trying out one of the picks of the week "print_pdf" and came across an error with the system() function. There is a line that builds and runs the following system command:
.....
cmd = 'gs';
options = [' -q -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile="' name '" -f "' tmp_nam '"'];
% Convert to pdf
[status result] = system([cmd options]);
.....
I get a status of 139 and the following message:
gs -q -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile="/path/NameOfFile.pdf" -f "/tmp/tempName.eps": Segmentation Fault
And the output pdf file is corrupt and can not be opened.
However if I copy and past the command into a terminal window (CSH) then the command executes and the PDF is generated as expected. It seems like Matlab is not passing the command to the system properly. I checked the PATHS variable with the matlab -n command and /usr/bin/ (which contains gs) is listed. Also I checked the variable SHELL and to make sure it was "csh".
Does anyone have any idea why Matlab could not execute this system command when it works in a CSH terminal?
Thanks is advance for any help.
Note: This is a 64-bit Linux system running Red Hat 4.
It is strange. Presumably you can run other system commands from MATLAB OK?
From the error message it looks like the segmentation fault is happening in ghostscript (caused by some strange interaction with MATLAB). Are you using the most recent release of gs? If not, try updating that.
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.