# Get current execution environment

**URL:** <https://www.ruby-forum.com/t/get-current-execution-environment/208881>\
**Category:** Ruby\
**Created:** [June 29, 2011, 5:33pm UTC](https://www.ruby-forum.com/t/get-current-execution-environment/208881 "2011-06-29T17:33:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 29, 2011, 5:33pm UTC](https://www.ruby-forum.com/t/get-current-execution-environment/208881/1 "2011-06-29T17:33:44Z")

</div>

I am writing a script that will need to run in both cygwin and the  
windows cmd shell. That being said I need a way to determine which one  
of them my script is running in.

When I use ENV[‘os’] or RUBY\_PLATFORM I am getting information about the  
actually OS not the execution environment.

Is there a way to determine the execution environment of a ruby script?

Thanks  
Hunter

---

<div class="post-metadata">

**Author:** ![mcmillhj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ab992/32.png) [@mcmillhj](https://www.ruby-forum.com/u/mcmillhj)\
**Post date:** [June 29, 2011, 6:44pm UTC](https://www.ruby-forum.com/t/get-current-execution-environment/208881/2 "2011-06-29T18:44:01Z")

</div>

You might check whether any of these env vars (from my MSYS) are  
available in cygwin and not in cmd.exe:

TERM  
PWD  
OLDPWD  
MSYSCON  
PS1  
SHLVL  
MSYSTEM  
\_

What are you trying to do from Ruby that requires this knowledge?

Jon

---

<div class="post-metadata">

**Author:** ![mcmillhj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ab992/32.png) [@mcmillhj](https://www.ruby-forum.com/u/mcmillhj)\
**Post date:** [June 29, 2011, 7:38pm UTC](https://www.ruby-forum.com/t/get-current-execution-environment/208881/3 "2011-06-29T19:38:48Z")

</div>

Jon F. wrote in post #1008271:

> What are you trying to do from Ruby that requires this knowledge?
> 
> Jon

During the execution of my script I query a mysql database and export  
XML files, I don’t need the files after execution so as the last step I  
want my script to remove the XML files from the directory.

On windows I would normally use: DEL \*.xml  
On Linux/Cygwin: rm \*.xml

Hunter

---

<div class="post-metadata">

**Author:** ![mcmillhj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ab992/32.png) [@mcmillhj](https://www.ruby-forum.com/u/mcmillhj)\
**Post date:** [June 29, 2011, 8:15pm UTC](https://www.ruby-forum.com/t/get-current-execution-environment/208881/4 "2011-06-29T20:15:30Z")

</div>

Try these…

[http://rubydoc.info/stdlib/core/1.9.2/File#delete-class\_method](http://rubydoc.info/stdlib/core/1.9.2/File#delete-class_method)

[http://rubydoc.info/stdlib/fileutils/1.9.2/file/README.rdoc](http://rubydoc.info/stdlib/fileutils/1.9.2/file/README.rdoc)

[http://rubydoc.info/stdlib/core/1.9.2/Dir#glob-class\_method](http://rubydoc.info/stdlib/core/1.9.2/Dir#glob-class_method)

---

<div class="post-metadata">

**Author:** ![mcmillhj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ab992/32.png) [@mcmillhj](https://www.ruby-forum.com/u/mcmillhj)\
**Post date:** [June 30, 2011, 3:12pm UTC](https://www.ruby-forum.com/t/get-current-execution-environment/208881/5 "2011-06-30T15:12:00Z")

</div>

Thanks, this works out much better than what I was looking for.

Hunter
