Journal the_mad_poster's Journal: A Few Unix Tools On Windows... Written In Perl 12
Update: Heh.
Because I am, again, banned from posting at this IP (even though I haven't posted here in over 4 days, and only got one downmod on this IP address in about a week), I am now deluging you with JEs.
This is probably useless to most people thanks to the cygwin environment and actual ports of the GNU utilities, but let me explain...
At work, I am not allowed to download and install applications. I frequently found myself pining for grep, but didn't want to waste my time trying to get somebody to install it for me. So, since I have perl on my system, I built my own customized version. From there, I thought "man, it would be nice if I could run this from anywhere with just 'grep'", so I made "alias". Well, after awhile, I collected the few tools I thought I needed, and now I'm putting them out for anyone who might want their own copy of the set. The tools don't necessarily (actually, they don't USUALLY) function just like the UNIX equivalents because I customized them to my needs and left a lot of stuff I didn't need out, but hey, they're good for study if nothing else.
Note that you will need Perl installed to run these. You can get a Windows Perl installer from http://www.activestate.com/.
Here are the tools in the system:
grep
search for files (sort of like UNIX's find command) or search text for strings matching a pattern.
alias
map a new command name to an existing command. For example, 'alias "dir/p /AD" dp' will give you a command named 'dp' that displays only directories and pauses with each screenful of results. Note that you have to surround arguments with spaces with "..".
clear
Runs 'cls'
rm
Runs 'del'
count
Display a line, character, and characters/line count of a file.
touch
Create an empty file.
ifconfig
Runs 'ipconfig'
ls
Runs 'dir'
man
Runs 'help'
uname
Runs 'ver'
yes
Runs ';'. Guaranteed to always return a successful exit status.
dump
Outputs a *.bat listing of windows/system32 (unless you have your own.bat files in there, it just tells you what unix-like commands you have on the system).
With the exception of touch, grep, alias, and count, most of this is just a bunch of
Important Usage Notes
- When providing a directory to grep, count, touch or alias, you're expected to use the / separator. You'll have to surround the pathname with double quotes ("..") because / in Windows terms is the character that signifies the start of a command argument. If this bothers you, you can usually use \ instead, but some output may look funny.
- Remember, any single argument that has spaces in it - and this is especially common when using alias - must be surrounded by double quotes. This is not strange, you have to do the same thing in UNIX-y systems, you just use single quotes instead.
- Whenever something wants a "pattern" as an argument - grep, for example - it expects the pattern to be interpretable by Perl. If you want to force literal interpretation, use '^your_string_here$'. Particularly useful for finding files with grep.
- Do not alias alias to alias! Seriously. Go for it. I dare you to try it. Chicken. Braaaak-brak-brak-brak.
Download here and simply unzip the contents into your windows/system32 directory. The system assumes you installed perl at "c:/perl/bin/perl", so, if you didn't, you'll have to go through each file (.bat and
Update: I don't know why this keeps defaulting to "Comments Disabled"....
Cool tools (Score:2)
How about the ultimate tool? (Score:2)
Wicked! (Score:2)
Thanks tons...
Pixie
Crap. (Score:2)
Sigh. Thanks anyways, TMP!
Pix
Re:Crap. (Score:1)
No promises though, Ms. Pixie.
Re:Crap. (Score:2)
You cheered me up after a dreadful night of desperate shopping, thank you!
Pixie
Re:Crap. (Score:2)
Hey, has anyone played with ActiveState's ability to compile Perl for Win32? I think it requires the purchase of their IDE, is it actually worth it?
Cheers,
=Blue(23)
Why not just use the PPT distro? (Score:2)
Seriously guys, google around a bit before reinventing the wheel.
Re:Why not just use the PPT distro? (Score:1)
I also don't see it on perl.org or cpan.org. Got a tip?
Re:Why not just use the PPT distro? (Score:2)
Re:Why not just use the PPT distro? (Score:1)
I MEANT how would one who does not have a direct link easily find it? It doesn't appear to be readily available via google or perl.org's index.
You might want to try ... (Score:2)
http://www.ka.net/jmenees/Dos/Set.htm [ka.net]
For example, if you want to list your directories differently, use SET DIRCMD=.
You can put this in a batch file that sets the appropriate variable, runs the command using the rest of the parameters (%2 %3 %4 .. %9), then UNSET DIRCMD. This way, you can have different batch files that do different things with the same command.
Also, you might not be allowed to install software, but y