Can a ruby script perform a chdir on win xp?

>
> > "Bill Guindon" <agorilla@gmail.com> writes:
> >
> > >> "Bill Guindon" <agorilla@gmail.com> writes:
> > >>
> > >> >
> > >> > I like the look of it, but it's not working here:
> > >> >
> > >> > c:\work\active\apps>cdir.bat
> > >> > (`cdir.rb`) was unexpected at this time.
> > >>
> > >> Hmm ... I wonder if this needs to run in a .cmd file instead of a
> .bat
> > >> file. Under winxp, it works for me in a .cmd file exactly as
> written.
> > >> Maybe if you rename your file to be cdir.cmd ... ???
> > >>
> > >
> > > Same results. Deleted the .bat file, and called it explicitly
> > > (cdir.cmd) to make sure.
> >
> > Actually, I had to do this:
> >
> > `\path\to\ruby.exe cdir.rb` instead of just `cdir.rb`
> >
> > I accidentaly copied and pasted the command line that I posted here from
> > an earlier version that didn't work. I'm sorry for the confusion.
> >
> Nope, that didn't help (yet). Not sure that 'unfortunately' applies here
> btw :wink:
>
> > But I'm sure that this is do-able in windows, one way or the other.
>
> I'm inclined to agree, and thanks much for trying. If nothing else,
> you gave me food for thought, and a couple of search terms.

a slightly less trickey way to do it (and apologies if this was already
proposed, I've been kinda skimming this thread up til now) would be to call
your ruby program from a cmd file, and call another cmd file right after.
then your ruby program could re-write the second cmd file.

like this:

doit.cmd contents:
    ruby myprog.rb
    followup.cmd

followup.cmd contents (written by myprog.rb):
    cd c:\whatever\

..pretty sure this would work, if you can't get the originally proposed
command line magic to work. It'd work as .bat files too, so you could use
it in Win98 or DOS or whatever.

Why was that so obvious _after_ I read it? Thanks much. Works like a charm.

···

On 4/30/06, Daniel Baird <danielbaird@gmail.com> wrote:

On 4/30/06, Bill Guindon <agorilla@gmail.com> wrote:
> On 4/29/06, Lloyd Zusman <ljz@asfast.com> wrote:
> > > On 4/29/06, Lloyd Zusman <ljz@asfast.com> wrote:

Cheers

;Daniel

--
Daniel Baird
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog :: Things
That Suck)

--
Bill Guindon (aka aGorilla)
The best answer to most questions is "it depends".

> [..snip!..]
> ..pretty sure this would work, if you can't get the originally proposed
> command line magic to work. It'd work as .bat files too, so you could
use
> it in Win98 or DOS or whatever.

Why was that so obvious _after_ I read it? Thanks much. Works like a
charm.

Hey.. I just *helped* someone on ruby-talk! First time -- woohoo!

Not a very Ruby related problem though.. but still..

;D

···

--
Daniel Baird
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog :: Things
That Suck)

>
> > [..snip!..]
> > ..pretty sure this would work, if you can't get the originally proposed
> > command line magic to work. It'd work as .bat files too, so you could
> use
> > it in Win98 or DOS or whatever.
>
> Why was that so obvious _after_ I read it? Thanks much. Works like a
> charm.
>
Hey.. I just *helped* someone on ruby-talk! First time -- woohoo!

Not a very Ruby related problem though.. but still..

Sure it was, it's how I got Rake to drop me off in the newly created
directory when I give it a 'new_app' task :slight_smile:

···

On 4/30/06, Daniel Baird <danielbaird@gmail.com> wrote:

;D

--
Daniel Baird
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog :: Things
That Suck)

--
Bill Guindon (aka aGorilla)
The best answer to most questions is "it depends".