Katherine McClintic

Katherine McClintic

Software Engineer

Email Me

Running Ruby Scripts with DOSKEY

3/25/2015

Sometimes Developing on Windows is Hard

In a very general sense one creates a temporary DOSKEY macro (similar to an alias) using the following syntax.


DOSKEY (command)=(thing you want it to do)

You then run it by calling the command you named. For more examples and more complex things that you can do, check out the post here. It's not great, but there aren't too many great examples out there.

Let’s say you want to run a ruby script a bunch of times, but you want to do so temporarily (no permanent changes/aliasing). As long as you’re within the same command session it’s pretty simple, but there are a couple of things to watch out for.

If your script involves ARGV in some way, you have to include that in your macro definition. The following will not work to display/run whatever’s triggered by a user’s question command:


DOSKEY roll=ruby file_name.rb
roll question

You have to set the command to include the possible entry options. The following will work for the above scenario, assuming that your underlying Ruby code works.


DOSKEY question=ruby file_name.rb question
question

You will have to reset these if you leave the session, but if you’re doing something temporary like running a script to test someone’s knowledge before a test or interview, this works pretty well.