<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243387</link>
    <title>MATLAB Central Newsreader - System Command</title>
    <description>Feed for thread: System Command</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 29 Jan 2009 20:21:01 -0500</pubDate>
      <title>System Command</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243387#624860</link>
      <author>Ben </author>
      <description>I was trying out one of the picks of the week &quot;print_pdf&quot; and came across an error with the system() function.  There is a line that builds and runs the following system command:&lt;br&gt;
.....&lt;br&gt;
cmd = 'gs';&lt;br&gt;
options = [' -q -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=&quot;' name '&quot; -f &quot;' tmp_nam '&quot;'];&lt;br&gt;
% Convert to pdf&lt;br&gt;
[status result] = system([cmd options]);&lt;br&gt;
.....&lt;br&gt;
I get a status of 139 and the following message:&lt;br&gt;
gs  -q -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=&quot;/path/NameOfFile.pdf&quot; -f &quot;/tmp/tempName.eps&quot;: Segmentation Fault&lt;br&gt;
&lt;br&gt;
And the output pdf file is corrupt and can not be opened.&lt;br&gt;
&lt;br&gt;
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 &quot;csh&quot;.&lt;br&gt;
&lt;br&gt;
Does anyone have any idea why Matlab could not execute this system command when it works in a CSH terminal?&lt;br&gt;
&lt;br&gt;
Thanks is advance for any help.&lt;br&gt;
Note: This is a 64-bit Linux system running Red Hat 4.</description>
    </item>
    <item>
      <pubDate>Thu, 29 Jan 2009 20:38:02 -0500</pubDate>
      <title>Re: System Command</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243387#624863</link>
      <author>Ben </author>
      <description>Forgot to mention I am using Matlab 2006b</description>
    </item>
    <item>
      <pubDate>Tue, 03 Feb 2009 14:54:02 -0500</pubDate>
      <title>Re: System Command</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243387#625735</link>
      <author>Oliver Woodford</author>
      <description>It is strange. Presumably you can run other system commands from MATLAB OK?&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
Aside from that, I'm afraid I can't help.&lt;br&gt;
Oliver</description>
    </item>
    <item>
      <pubDate>Tue, 03 Feb 2009 23:24:02 -0500</pubDate>
      <title>Re: System Command</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243387#625873</link>
      <author>Ben </author>
      <description>Yes, I can run other system commands just fine.&lt;br&gt;
&lt;br&gt;
I am not sure about the Ghost Script version but it works via CSH command line.&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
So I am leaning towards some kind of bug in 2006b.</description>
    </item>
  </channel>
</rss>

