Thread Subject: System Command

Subject: System Command

From: Ben

Date: 29 Jan, 2009 20:21:01

Message: 1 of 4

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.

Subject: System Command

From: Ben

Date: 29 Jan, 2009 20:38:02

Message: 2 of 4

Forgot to mention I am using Matlab 2006b

Subject: System Command

From: Oliver Woodford

Date: 3 Feb, 2009 14:54:02

Message: 3 of 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.

Aside from that, I'm afraid I can't help.
Oliver

Subject: System Command

From: Ben

Date: 3 Feb, 2009 23:24:02

Message: 4 of 4

Yes, I can run other system commands just fine.

I am not sure about the Ghost Script version but it works via CSH command line.

One interesting note is that I am currently using 2006b. I tried the command using Matlab 2008a on the same machine and it works perfectly.

So I am leaning towards some kind of bug in 2006b.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
gs Ben 29 Jan, 2009 15:25:03
pdf Ben 29 Jan, 2009 15:25:03
print Ben 29 Jan, 2009 15:25:03
rssFeed for this Thread

Contact us at files@mathworks.com