Hi,
I am wondering if it is possible to write a Ruby script to change the
directory, inside a Command Prompt window?
I want to do something like:
Before:
c:>ruby rubychdir.rbw data
After:
c:\data>
Is this just not possible?
Thanks,
Nick.
Hi,
I am wondering if it is possible to write a Ruby script to change the
directory, inside a Command Prompt window?
I want to do something like:
Before:
c:>ruby rubychdir.rbw data
After:
c:\data>
Is this just not possible?
Thanks,
Nick.
Hi,
I am wondering if it is possible to write a Ruby script to change the
directory, inside a Command Prompt window?
I want to do something like:
Before:
c:>>ruby rubychdir.rbw data
After:
c:\data>>
Is this just not possible?
Just not possible. A Ruby program, like any other program, can only
affect the environment of its own process and child processes.
Gavin
On Friday, March 28, 2003, 9:55:42 AM, Nick wrote:
Gavin 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?
@rem = '–Ruby–
@echo off
if “%TEMP%” == “” (
echo TEMP not set
goto exit 2>nul
)
SET ARG=%1
if “%1” == “” (
SET ARG=nil
)
set TMP_BAT_FILE=%TEMP%\TMPBAT_%RANDOM%.bat
:exec
ruby -x -S Test.bat %TMP_BAT_FILE% %1 %2 %3
goto endofruby
@rem ';
#!ruby
END
:endofruby
@echo off
if exist %TMP_BAT_FILE% call %TMP_BAT_FILE%
del %TMP_BAT_FILE% 2> nul
set TMP_BAT_FILE=
Hi Gavin, you might be right. I am not 100% sure, though I do remember
having a DOS tool that did exactly what I want to do when executed wihtin a
DOS Shell in NT4.
Nick.
“Gavin Sinclair” gsinclair@soyabean.com.au wrote in message
news:94316532409.20030328110823@soyabean.com.au…
On Friday, March 28, 2003, 9:55:42 AM, Nick wrote:
Hi,
I am wondering if it is possible to write a Ruby script to change the
directory, inside a Command Prompt window?I want to do something like:
Before:
c:>>ruby rubychdir.rbw dataAfter:
c:\data>>Is this just not possible?
Just not possible. A Ruby program, like any other program, can only
affect the environment of its own process and child processes.Gavin
Patrick,
Very interesting !
In your script Test.bat, what do the following lines accomplish:
first line> @rem = '–Ruby–
line# 16> @rem ';
last line> set TMP_BAT_FILE=
Thanks,
– shanko
"Patrick Bennett" patrick.bennett@inin.com wrote in message news:3E8394E9.3000901@inin.com…
Gavin 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?
@rem = '–Ruby–
@echo off
if “%TEMP%” == “” (
echo TEMP not set
goto exit 2>nul
)
SET ARG=%1
if “%1” == “” (
SET ARG=nil
)
set TMP_BAT_FILE=%TEMP%\TMPBAT_%RANDOM%.bat
:exec
ruby -x -S Test.bat %TMP_BAT_FILE% %1 %2 %3
goto endofruby
@rem ';
#!ruby
END
:endofruby
@echo off
if exist %TMP_BAT_FILE% call %TMP_BAT_FILE%
del %TMP_BAT_FILE% 2> nul
set TMP_BAT_FILE=
Thanks for that Patrick, I will take a look at it.
“Patrick Bennett” patrick.bennett@inin.com wrote in message
news:3E8394E9.3000901@inin.com…
Gavin 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?
@rem = '–Ruby–
@echo off
if “%TEMP%” == “” (
echo TEMP not set
goto exit 2>nul
)
SET ARG=%1
if “%1” == “” (
SET ARG=nil
)
set TMP_BAT_FILE=%TEMP%\TMPBAT_%RANDOM%.bat
:exec
ruby -x -S Test.bat %TMP_BAT_FILE% %1 %2 %3
goto endofruby
@rem ';
#!ruby
END
:endofruby
@echo off
if exist %TMP_BAT_FILE% call %TMP_BAT_FILE%
del %TMP_BAT_FILE% 2> nul
set TMP_BAT_FILE=
“Nick” nick.robinson@f.co.uk writes:
Hi Gavin, you might be right. I am not 100% sure, though I do remember
having a DOS tool that did exactly what I want to do when executed wihtin a
DOS Shell in NT4.
You can do that in DOS (and presumably a DOS emulator running on NT4)
due to the fact that DOS stored information in a global memory area
that anybody could access if they took the time and figured out how.
No doubt the emulator emulates the memory accesses that perform this
function.
You might be able to do something like that with a C extension to
Ruby, I suppose, but you’re much better off rethinking your
problem.
-=Eric
–
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton.