Path: news.mathworks.com!not-for-mail
From: "Ben" <basburywvu.nospam@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: System Command
Date: Thu, 29 Jan 2009 20:21:01 +0000 (UTC)
Organization: Orbital Sciences Corp
Lines: 18
Message-ID: <glt33d$c91$1@fred.mathworks.com>
Reply-To: "Ben" <basburywvu.nospam@hotmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1233260461 12577 172.30.248.35 (29 Jan 2009 20:21:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 29 Jan 2009 20:21:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 425457
Xref: news.mathworks.com comp.soft-sys.matlab:514820


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.