How to set current directory for OSProcess?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set current directory for OSProcess?

Simon Guest-2
Background: I'm trying to call LaTeX from Squeak using OSProcess, so I
can have nicely formatted maths formulae, using LaTeX preview mode and
Ghostscript to generate PNG files from the PDF that LaTeX produces.

But I'm stuck trying to invoke a command such as pdflatex.exe from
Squeak in a directory of my choosing.

So, having created a temporary directory, how do I run my command in a
sub-process with that as the current directory?

cheers,
Simon


Reply | Threaded
Open this post in threaded view
|

Re: How to set current directory for OSProcess?

Giovanni Giorgi-3
Mmmmhh the simpler answer is: do a batch (.bat) passing it the
directory as  parameter...



On 10/27/06, Simon Guest <[hidden email]> wrote:

> Background: I'm trying to call LaTeX from Squeak using OSProcess, so I
> can have nicely formatted maths formulae, using LaTeX preview mode and
> Ghostscript to generate PNG files from the PDF that LaTeX produces.
>
> But I'm stuck trying to invoke a command such as pdflatex.exe from
> Squeak in a directory of my choosing.
>
> So, having created a temporary directory, how do I run my command in a
> sub-process with that as the current directory?
>
> cheers,
> Simon
>
>
>


--
"Just Design It" -- GG
Software Architect
http://www.objectsroot.com/

Reply | Threaded
Open this post in threaded view
|

Re: How to set current directory for OSProcess?

David T. Lewis
In reply to this post by Simon Guest-2
On Fri, Oct 27, 2006 at 01:07:25PM +0100, Simon Guest wrote:
>
> But I'm stuck trying to invoke a command such as pdflatex.exe from
> Squeak in a directory of my choosing.
>
> So, having created a temporary directory, how do I run my command in a
> sub-process with that as the current directory?

Simon,

Are you using Windows or some flavor of Unix?

Dave


Reply | Threaded
Open this post in threaded view
|

Re: How to set current directory for OSProcess?

David T. Lewis
In reply to this post by Simon Guest-2
On Fri, Oct 27, 2006 at 01:07:25PM +0100, Simon Guest wrote:
> Background: I'm trying to call LaTeX from Squeak using OSProcess, so I
> can have nicely formatted maths formulae, using LaTeX preview mode and
> Ghostscript to generate PNG files from the PDF that LaTeX produces.
>
> But I'm stuck trying to invoke a command such as pdflatex.exe from
> Squeak in a directory of my choosing.
>
> So, having created a temporary directory, how do I run my command in a
> sub-process with that as the current directory?
 
Simon,

If you are using a Unix/Linux/OS X machine, one way to do this sort
of thing is with a CommandShell script:

cs := CommandShell new open; yourself.
cs script:
'echo change directory to /tmp
cd /tmp
pwd
echo do some LaTeX stuff here
echo you can use pipelines also | cat
sleep 4
/usr/bin/noSuchCommand
exit'
  onFailureDo: [:p |
    cs command: 'exit'.
    'the command that failed was ', p printString]

You don't actually need to open the CommandShell window, but it helps
to do so while you are debugging your scripts.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: How to set current directory for OSProcess?

Simon Guest-2
In reply to this post by David T. Lewis
At Fri, 27 Oct 2006 16:35:43 -0400,
David T Lewis wrote:
> Are you using Windows or some flavor of Unix?

I'm on Windows, which is where I'd like to make this work first.

cheers,
Simon


Reply | Threaded
Open this post in threaded view
|

Re: How to set current directory for OSProcess?

David T. Lewis
On Sat, Oct 28, 2006 at 03:00:05PM +0100, Simon Guest wrote:
> At Fri, 27 Oct 2006 16:35:43 -0400,
> David T Lewis wrote:
> > Are you using Windows or some flavor of Unix?
>
> I'm on Windows, which is where I'd like to make this work first.

You will probably need to follow Giovanni's advice and use some sort
of .BAT file. Also, on Windows it is probably easier to use Win32Shell
(in FFI-Examples-Win32), since the FFI plugin is more likely to be
on your system already.

Dave
 

Reply | Threaded
Open this post in threaded view
|

Re: How to set current directory for OSProcess?

Simon Guest-2
At Sat, 28 Oct 2006 10:47:39 -0400,
David T Lewis wrote:
> You will probably need to follow Giovanni's advice and use some sort
> of .BAT file. Also, on Windows it is probably easier to use Win32Shell
> (in FFI-Examples-Win32), since the FFI plugin is more likely to be
> on your system already.
 
Dave,

Thanks, I'll give it a go.  I like your suggestion of the use of
CommandShell on Linux, so I'll probably also try that (on my other
box).

cheers,
Simon