From: Shashank Date Date: 2003-03-28T14:36:12+09:00 Subject: Re: Windows Platform - changing directory of caller? This is a multi-part message in MIME format. ------=_NextPart_000_003F_01C2F4B8.086323F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Patrick, Very interesting !=20 In your script Test.bat, what do the following lines accomplish: first line> @rem =3D '--Ruby-- line# 16> @rem '; last line> set TMP_BAT_FILE=3D=20 Thanks, -- shanko "Patrick Bennett" wrote in message = news:3E8394E9.3000901@inin.com... Gavin Sinclair wrote: On Friday, March 28, 2003, 9:55:42 AM, Nick wrote: =20 I am wondering if it is possible to write a Ruby script to change the directory, inside a Command Prompt window? =20 What we've done at my company for some internal scripts is create a = batch file that contains Ruby code, which in turn creates a temporary = batch file which the outer batch file then executes. ie: =20 Test.bat --- @rem =3D '--Ruby-- @echo off if "%TEMP%" =3D=3D "" ( echo TEMP not set goto exit 2>nul ) SET ARG=3D%1 if "%1" =3D=3D "" ( SET ARG=3Dnil ) set TMP_BAT_FILE=3D%TEMP%\TMPBAT_%RANDOM%.bat :exec ruby -x -S Test.bat %TMP_BAT_FILE% %1 %2 %3 goto endofruby @rem '; #!ruby # ruby code here # write out Windows shell commands to the ARGV[0] filename __END__ :endofruby @echo off if exist %TMP_BAT_FILE% call %TMP_BAT_FILE% del %TMP_BAT_FILE% 2> nul set TMP_BAT_FILE=3D ------=_NextPart_000_003F_01C2F4B8.086323F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Patrick,
 
Very interesting !
In your script Test.bat, what do the following lines accomplish:
 
first line> @rem =3D = '--Ruby--
line# 16> @rem=20 ';
last line> 
set TMP_BAT_FILE=3D=20
 
Thanks,
-- shanko
"Patrick Bennett" <patrick.bennett@inin.com>= wrote=20 in message news:3E8394E9.3000901@inin.com...
Gavin=20 Sinclair wrote:
On Friday, March 28, 2003, 9:55:42 AM, Nick =
wrote:

  
I am wondering if it is =
possible to write a Ruby script to change the
directory, inside a Command Prompt window?
    
What we've done at my company for = some=20 internal scripts is create a batch file that contains Ruby code, which = in turn=20 creates a temporary batch file which the outer batch file then=20 executes.
ie:  
Test.bat
---
@rem =3D = '--Ruby--
@echo=20 off
if "%TEMP%" =3D=3D "" (
    echo TEMP not=20 set
    goto exit 2>nul
)
SET = ARG=3D%1
if "%1" =3D=3D=20 "" (
    SET ARG=3Dnil
)
set=20 TMP_BAT_FILE=3D%TEMP%\TMPBAT_%RANDOM%.bat

:exec
ruby -x -S = Test.bat=20 %TMP_BAT_FILE% %1 %2 %3
goto endofruby
@rem = ';
#!ruby

# ruby=20 code here
# write out Windows shell commands to the ARGV[0]=20 filename
__END__
:endofruby
@echo off
if exist = %TMP_BAT_FILE% call=20 %TMP_BAT_FILE%
del %TMP_BAT_FILE% 2> nul
set = TMP_BAT_FILE=3D

------=_NextPart_000_003F_01C2F4B8.086323F0--