tag:blogger.com,1999:blog-50891787619652174982024-02-06T20:14:40.371-06:00a traveller from an antique landa brief and biased look at the state of computer technology today.Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.comBlogger39125tag:blogger.com,1999:blog-5089178761965217498.post-39213874030310334492016-08-16T15:44:00.000-05:002016-08-16T15:44:23.506-05:00<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/src=header">
<h1 id="random-vs-urandom" style="border-bottom: 1px solid rgb(221, 221, 221); font-size: 1.6em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Random vs. Urandom</h1>
<div style="margin: 0px 0px 1.2em !important;">
<em>“You keep using that word. I don’t think that word means what you think it means.”</em></div>
<div style="margin: 0px 0px 1.2em !important;">
I’ve been told for most of my professional life that <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">/dev/random</code> was “better” than <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">/dev/urandom</code>, that one was inherently more secure and sophisticated than the other. I bought it, because it made sense based upon <em>the little I know about cryptography.</em> And there’s the rub. Most of us aren’t experts in the field. This <a href="http://www.2uo.de/myths-about-urandom/">cool little article</a> delves into some good explanations of what is meant by “random” and why it matters. It may turn some of your preciously-held notions upside down, but that’s okay. The day we stop learning is the day we start dying.</div>
<div style="margin: 0px 0px 1.2em !important;">
Be seeing you!</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+IyBSYW5kb20gdnMuIFVyYW5kb208L3A+PHA+PGJyPjwvcD48cD4qIllvdSBrZWVwIHVzaW5n
IHRoYXQgd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585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-59388250391186306492016-01-12T10:32:00.000-06:002016-01-12T11:44:32.106-06:00Load Average: those funny little numbers<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=5938825039118630649">
<div style="margin: 0px 0px 1.2em !important;">
I was going to write a little article on interpreting the <em>load average</em> in UNIX and Linux machines, but I ran across <a href="http://www.howtogeek.com/194642/understanding-the-load-average-on-linux-and-other-unix-like-systems/">this blog post</a> and don’t think I could have said it better. Really, check it out.</div>
<div style="margin: 0px 0px 1.2em !important;">
When I’m logged into a graphical session on my FreeBSD system I use <a href="http://conky.sourceforge.net/screenshots.html">conky</a> to monitor hardware utilization and performance (and the local weather and unread messages in my GMail inbox, etc.) But normally I work from the command line with <a href="https://simple.wikipedia.org/wiki/Secure_Shell">ssh</a> and <a href="https://tmux.github.io/">tmux</a>, so I have created an alias that I load in my login profile to let me get at the load average in a quick-and-easy fashion:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">alias loadavg='sysctl vm.loadavg | cut -d" " -f3,4,5'
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Now I just run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">loadavg</code> any time I want to see how my cpu cores are doing.</div>
<div style="margin: 0px 0px 1.2em !important;">
Be seeing you.</div>
<div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Rhcmdl
dD0iX2JsYW5rIj5zc2g8L2E+IGFuZCA8YSBocmVmPSJodHRwczovL3RtdXguZ2l0aHViLmlvLyIg
dGFyZ2V0PSJfYmxhbmsiPnRtdXg8L2E+LCBzbyBJIGhhdmUgY3JlYXRlZCBhbiBhbGlhcyB0aGF0
IEkgbG9hZCBpbiBteSBsb2dpbiBwcm9maWxlIHRvIGxldCBtZSBnZXQgYXQgdGhlIGxvYWQgYXZl
cmFnZSBpbiBhIHF1aWNrLWFuZC1lYXN5IGZhc2hpb246PC9wPjxwPjxicj48L3A+PHA+YGBgPC9w
PjxwPmFsaWFzIGxvYWRhdmc9J3N5c2N0bCB2bS5sb2FkYXZnIHwgY3V0IC1kIiAiIC1mMyw0LDUn
PC9wPjxwPmBgYDwvcD48cD48YnI+PC9wPjxwPk5vdyBJIGp1c3QgcnVuIGBsb2FkYXZnYCBhbnkg
dGltZSBJIHdhbnQgdG8gc2VlIGhvdyBteSBjcHUgY29yZXMgYXJlIGRvaW5nLjwvcD48cD48YnI+
PC9wPjxwPkJlIHNlZWluZyB5b3UuPC9wPg==">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-26922229997594500622015-09-25T15:56:00.000-05:002017-10-17T09:39:12.107-05:00More on Editing Multiple Documents in vim<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=2692222999759450062;onPublishedMenu=allposts;onClosedMenu=allposts;postNum=3;src=postname" style="font-family: Charter,Georgia,Times New Roman,serif; font-size: 110%; line-height: 140%;">
<h1 id="using-vim-windows" style="border-bottom: 1px solid rgb(221, 221, 221); font-family: Charter,Georgia,Times New Roman,serif; font-size: 1.8em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Using vim Windows</h1>
<div style="margin: 0px 0px 1.2em !important;">
We’ve talked about <a href="http://mechatechzilla.blogspot.com/2015/09/editing-multiple-documents-in-vim.html">using buffers to edit multiple documents in vim.</a> Each file lives in a buffer which, in turn, lives in it’s own tab page, rather like a tab in a web browser. But sometimes I want to view one file while editing another, and it would be handy to have both files in the same screen at once. To support that, vim gives us <em>windows.</em></div>
<div style="margin: 0px 0px 1.2em !important;">
To split the screen into multiple windows in vim, switch to command mode and run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:split</code> or <strong>control-w</strong> followed by <strong>s</strong>. This will split the screen into two windows, each containing a copy of the file that was in the original screen. Running <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:split</code> again will create a third pane, and so on.</div>
<div style="margin: 0px 0px 1.2em !important;">
If you want to open the new pane with a different file, run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:split myfile</code>. This will open a new window with the other file loaded inside. To open a window with a new, blank file, run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:new</code> or <strong>control-w n</strong>.</div>
<div style="margin: 0px 0px 1.2em !important;">
The active window can be resized with with the command <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:resize #</code> or <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">z#</code>, where the <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">#</code> sign is the number of lines high that the window should be. </div>
<div style="margin: 0px 0px 1.2em !important;">
To move up and down among the visible windows use <strong>control-w k</strong> and <strong>control-w j</strong> respectively. To close the selected window, run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:close</code> or press <strong>control-w c</strong>.</div>
<div style="margin: 0px 0px 1.2em !important;">
There are actually many commands to manipulate buffers and windows in vim. These are the basics and will get you through most common tasks. To learn more, go to vim’s command mode and run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:help window</code>.</div>
<div style="margin: 0px 0px 1.2em !important;">
Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+VXNpbmcgdmltIFdpbmRvd3M8YnI+PT09PT09PT09PTxicj48L3A+PHA+PGJyPjwvcD48cD5X
ZSd2ZSB0YWxrZWQgYWJvdXQgW3VzaW5nIGJ1ZmZlcnMgdG8gZWRpdCBtdWx0aXBsZSBkb2N1bWVu
dHMgaW4gdmltLl0oaHR0cDovL21lY2hhdGVjaHppbGxhLmJsb2dzcG90LmNvbS8yMDE1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xvYWRlZCBpbnNpZGUuIFRvIG9wZW4g
YSB3aW5kb3cgd2l0aCBhIG5ldywgYmxhbmsgZmlsZSwgcnVuIGA6bmV3YCBvciBfX2NvbnRyb2wt
dyBuX18uPC9wPjxwPjxicj48L3A+PHA+VGhlIGFjdGl2ZSB3aW5kb3cgY2FuIGJlIHJlc2l6ZWQg
d2l0aCB3aXRoIHRoZSBjb21tYW5kIGA6cmVzaXplICNgIG9yIGB6I2AsIHdoZXJlIHRoZSBgI2Ag
c2lnbiBpcyB0aGUgbnVtYmVyIG9mIGxpbmVzIGhpZ2ggdGhhdCB0aGUgd2luZG93IHNob3VsZCBi
ZS4mbmJzcDs8L3A+PHA+PGJyPjwvcD48cD5UbyBtb3ZlIHVwIGFuZCBkb3duIGFtb25nIHRoZSB2
aXNpYmxlIHdpbmRvd3MgdXNlIF9fY29udHJvbC13IGtfXyBhbmQgX19jb250cm9sLXcgal9fIHJl
c3BlY3RpdmVseS4gVG8gY2xvc2UgdGhlIHNlbGVjdGVkIHdpbmRvdywgcnVuIGA6Y2xvc2VgIG9y
IHByZXNzIF9fY29udHJvbC13IGNfXy48L3A+PHA+PGJyPjwvcD48cD5UaGVyZSBhcmUgYWN0dWFs
bHkgbWFueSBjb21tYW5kcyB0byBtYW5pcHVsYXRlIGJ1ZmZlcnMgYW5kIHdpbmRvd3MgaW4gdmlt
LiBUaGVzZSBhcmUgdGhlIGJhc2ljcyBhbmQgd2lsbCBnZXQgeW91IHRocm91Z2ggbW9zdCBjb21t
b24gdGFza3MuIFRvIGxlYXJuIG1vcmUsIGdvIHRvIHZpbSdzIGNvbW1hbmQgbW9kZSBhbmQgcnVu
IGA6aGVscCB3aW5kb3dgLjwvcD48cD48YnI+PC9wPjxwPkJlIHNlZWluZyB5b3UuPC9wPg==">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-39239527238520344912015-09-11T08:46:00.000-05:002015-10-07T15:16:55.060-05:00I'm an Alias, I'm a Legal Alias<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=3923952723852034491;onPublishedMenu=posts;onClosedMenu=posts;postNum=0;src=link">
<h1 id="useful-command-aliases" style="border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.6em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Useful Command Aliases</h1>
<div style="margin: 0px 0px 1.2em !important;">
When working from the command line I like to cut down on the amount of typing that I do because <strong>a)</strong> I get in a hurry, and <strong>b)</strong> I fat-finger the things I’m trying to type, so <strong>c)</strong> I end up doing things over to get them right. I use aliases to take some common tasks and shorten them up so that I can save time and face.</div>
<div style="margin: 0px 0px 1.2em !important;">
If you look at my *nix systems you’ll find several aliases for various incarnations of <strong>ls</strong>:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">alias l='ls -F'
alias la='ls -a'
alias ll='ls -lh'
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
The first of these, <strong>-F</strong>, appends a character to the end of the file name to identify the file type: <strong>*</strong> for executable files; <strong>@</strong> for symbolic links; and <strong>/</strong> for directories. Regular files don’t have any special character following their names. While most Linuxes and BSDs use a colorized <strong>ls</strong> command these days, this is useful if you need to work from a terminal or remote session that doesn’t support color.</div>
<div style="margin: 0px 0px 1.2em !important;">
The second alias lists all files, including hidden ones, and the third displays a detailed listing with file sizes in “human readable” format: gigabytes or megabytes instead of bytes.</div>
<div style="margin: 0px 0px 1.2em !important;">
Aliases <em>can</em> be more sophisticated, standing for piped output. When I use the <strong>df</strong> command to check free disk space, usually I just want to see mounted logical volumes and not pseudo-filesystems and LVM disks. I pipe the output of <strong>df</strong> to <strong>grep</strong> to get what I want:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">alias dfh='df -h | grep -v "^[[:alpha:]]"'
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
And to see a sorted list of details about my own processes:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">alias myps='ps aux | grep ^$(whoami) | sort -k 2b'
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
An alias can also contain several commands—a mini-script, if you will:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">alias sched='echo ""; cal; echo ""; calendar -w 3; echo ""'
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Perhaps I have inspired you to experiment with aliases and discover some of the cool things you can do with them.</div>
<div style="margin: 0px 0px 1.2em !important;">
Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+IyBVc2VmdWwgQ29tbWFuZCBBbGlhc2VzPC9wPjxwPjxicj48L3A+PHA+V2hlbiB3b3JraW5n
IGZyb20gdGhlIGNvbW1hbmQgbGluZSBJIGxpa2UgdG8gY3V0IGRvd24gb24gdGhlIGFtb3VudCBv
ZiB0eXBpbmcgdGhhdCBJIGRvIGJlY2F1c2UgKiphKSoqIEkgZ2V0IGluIGEgaHVycnksIGFuZCAq
KmIpKiogSSBmYXQtZmluZ2VyIHRoZSB0aGluZ3MgSSdtIHRyeWluZyB0byB0eXBlLCBzbyAqKmMp
KiogSSBlbmQgdXAgZG9pbmcgdGhpbmdzIG92ZXIgdG8gZ2V0IHRoZW0gcmlnaHQuIEkgdXNlIGFs
aWFzZXMgdG8gdGFrZSBzb21lIGNvbW1vbiB0YXNrcyBhbmQgc2hvcnRlbiB0aGVtIHVwIHNvIHRo
YXQgSSBjYW4gc2F2ZSB0aW1lIGFuZCBmYWNlLjwvcD48cD48YnI+PC9wPjxwPklmIHlvdSBsb29r
IGF0IG15IFwqbml4IHN5c3RlbXMgeW91J2xsIGZpbmQgc2V2ZXJhbCBhbGlhc2VzIGZvciB2YXJp
b3VzIGluY2FybmF0aW9ucyBvZiAqKmxzKio6PC9wPjxwPjxicj48L3A+PHA+YGBgYDwvcD48cD5h
bGlhcyBsPSdscyAtRic8L3A+PHA+YWxpYXMgbGE9J2xzIC1hJzwvcD48cD5hbGlhcyBsbD0nbHMg
LWxoJzwvcD48cD5gYGBgPC9wPjxwPjxicj48L3A+PHA+VGhlIGZpcnN0IG9mIHRoZXNlLCAqKi1G
KiosIG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bHVtZXMgYW5kIG5vdCBw
c2V1ZG8tZmlsZXN5c3RlbXMgYW5kIExWTSBkaXNrcy4gSSBwaXBlIHRoZSBvdXRwdXQgb2YgKipk
ZioqIHRvICoqZ3JlcCoqIHRvIGdldCB3aGF0IEkgd2FudDo8L3A+PHA+PGJyPjwvcD48cD5gYGBg
PC9wPjxwPmFsaWFzIGRmaD0nZGYgLWggfCBncmVwIC12ICJeW1s6YWxwaGE6XV0iJzwvcD48cD5g
YGBgPC9wPjxwPjxicj48L3A+PHA+QW5kIHRvIHNlZSBhIHNvcnRlZCBsaXN0IG9mIGRldGFpbHMg
YWJvdXQgbXkgb3duIHByb2Nlc3Nlczo8L3A+PHA+PGJyPjwvcD48cD5gYGBgPC9wPjxwPmFsaWFz
IG15cHM9J3BzIGF1eCB8IGdyZXAgXiQod2hvYW1pKSB8IHNvcnQgLWsgMmI8L3A+PHA+YGBgYDwv
cD48cD48YnI+PC9wPjxwPkFuIGFsaWFzIGNhbiBhbHNvIGNvbnRhaW4gc2V2ZXJhbCBjb21tYW5k
cy0tYSBtaW5pLXNjcmlwdCwgaWYgeW91IHdpbGw6PC9wPjxwPjxicj48L3A+PHA+YGBgYDwvcD48
cD5hbGlhcyBjYWw9J2VjaG8gIiI7IGNhbDsgZWNobyAiIjsgY2FsZW5kYXIgLXcgMzsgZWNobyAi
Iic8L3A+PHA+YGBgYDwvcD48cD48YnI+PC9wPjxwPlBlcmhhcHMgSSBoYXZlIGluc3BpcmVkIHlv
dSB0byBleHBlcmltZW50IHdpdGggYWxpYXNlcyBhbmQgZGlzY292ZXIgc29tZSBvZiB0aGUgY29v
bCB0aGluZ3MgeW91IGNhbiBkbyB3aXRoIHRoZW0uPC9wPjxwPjxicj48L3A+PHA+QmUgc2VlaW5n
IHlvdS48L3A+">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-86872206213530109722015-09-08T22:12:00.000-05:002017-10-17T09:38:35.566-05:00Editing Multiple Documents in vim<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=8687220621353010972;onPublishedMenu=allposts;onClosedMenu=allposts;postNum=5;src=link" style="font-family: Charter,Georgia,Times New Roman,serif; font-size: 110%; line-height: 140%;">
<h1 id="using-vim-buffers" style="border-bottom: 1px solid rgb(221, 221, 221); font-family: Charter,Georgia,Times New Roman,serif; font-size: 1.8em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Using vim Buffers</h1>
<div style="margin: 0px 0px 1.2em !important;">
When editing a file in vim it is stored and displayed in a <em>buffer,</em> something like a tab in a web browser window. You can open multiple files at once and easily move back and forth among the buffers to work with each file.</div>
<h2 id="opening-multiple-files-in-vim" style="border-bottom: 1px solid rgb(238, 238, 238); font-family: Charter,Georgia,Times New Roman,serif; font-size: 1.6em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Opening Multiple Files in vim</h2>
<div style="margin: 0px 0px 1.2em !important;">
To open multiple files in vim when you start your session, simply list them on the command line:</div>
<pre style="font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">$> vim myfile1 myfile2 myfile3 myfile4
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
This will start vim with four buffers pre-loaded with your four files. You can use wildcards:</div>
<pre style="font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">$> vim documents/myfile*
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
If you already have vim running and want to open another file, go to command mode and type:</div>
<pre style="font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">:e documents/myfile5
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
You’ll be happy to know that you can use tab completion with the <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:e</code> command. If you want to create a new file within vim, from command mode run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:enew</code> which will open an empty buffer. Just remember to save the file with a name anytime before you exit:</div>
<pre style="font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">:sav documents/myfile6
</code></pre>
<h2 id="navigating-among-files" style="border-bottom: 1px solid rgb(238, 238, 238); font-family: Charter,Georgia,Times New Roman,serif; font-size: 1.6em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Navigating Among Files</h2>
<div style="margin: 0px 0px 1.2em !important;">
To see the buffers open in your current session, from command mode run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:buffers</code>. Note that each buffer lists the file that it contains, and each has a unique number. To move to a different buffer, run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:b#</code> where the <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">#</code> sign represents the number you want to move to. For example, to begin editing the file in buffer number 3, run:</div>
<pre style="font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">:b3
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Keep in mind that before you can switch to a new buffer you must save or discard all the changes made to the current one. Use the <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:w</code> command to save your file before changing buffers.</div>
<div style="margin: 0px 0px 1.2em !important;">
You can cut, copy and paste among buffers just as you would within a single file. Just remember that if you make a cut you will need to save the changes in the current file before switching to the target buffer.</div>
<div style="margin: 0px 0px 1.2em !important;">
When you no longer want to work on a file you can close its buffer with the “buffer delete” command, <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">:bd</code>. This command closes the file in the current buffer and deletes the buffer; the file is not removed. By adding a number you can delete a specific buffer. For example:</div>
<pre style="font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">:bd3
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
This will close the file in buffer 3 and delete the buffer. And quitting vim will close all files and delete all buffers.</div>
<div style="margin: 0px 0px 1.2em !important;">
Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+VXNpbmcgdmltIEJ1ZmZlcnM8YnI+PT09PT09PT09PGJyPjwv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Rm9yIGV4
YW1wbGU6PC9wPjxwPjxicj48L3A+PHA+YGBgPC9wPjxwPjpiZDM8L3A+PHA+YGBgJm5ic3A7PC9w
PjxwPjxicj48L3A+PHA+VGhpcyB3aWxsIGNsb3NlIHRoZSBmaWxlIGluIGJ1ZmZlciAzIGFuZCBk
ZWxldGUgdGhlIGJ1ZmZlci4gQW5kIHF1aXR0aW5nIHZpbSB3aWxsIGNsb3NlIGFsbCBmaWxlcyBh
bmQgZGVsZXRlIGFsbCBidWZmZXJzLjwvcD48cD48YnI+PC9wPjxwPkJlIHNlZWluZyB5b3UuPC9w
Pg==">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-19397018542265880602015-09-03T09:00:00.000-05:002015-09-09T21:48:27.434-05:00PowerShell and Chocolatey Goodness<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=1939701854226588060;onPublishedMenu=posts;onClosedMenu=posts;postNum=0;src=postname">
<div style="margin: 0px 0px 1.2em !important;">
A movement has long been afoot to bring a useful package management system to Windows. If you’ve used <strong>apt</strong> or <strong>yum</strong> or <strong>yast</strong> or some similar tool in a Linux distribution, then you know how easy it can be to install new software to your computer with the right utility. Enter <a href="http://chocolatey.org/" title="a tasty treat"><em>chocolatey,</em></a> the PowerShell package manager for Windows.</div>
<div style="margin: 0px 0px 1.2em !important;">
Before starting a new class I make sure I load up my instructor computer with my favorite text editor and my chosen file manager:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">choco install -y vim doublecmd
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
If I’m going to play videos for my class, I may also add a nice player:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">choco install vlc
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Of course, if I see that the machine I’m using has an older version of PowerShell I may want to update that:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">choco install -y powershell4
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
What if I don’t know the name of the package I want? If I want to install the Angry IP network scan tool but know not what the package is called, I’ll ask chocolatey:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">choco search angry
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
This is such a cool tool that <a href="http://blogs.technet.com/b/windowsserver/archive/2014/04/03/windows-management-framework-v5-preview.aspx" title="PowerShell OneGet">rumor has it</a> that even Microsoft is interested in using it. We’ll see. Perhaps managing software in Windows will soon be as easy as it is in Linux.</div>
<div style="margin: 0px 0px 1.2em !important;">
Bee seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+QSBtb3ZlbWVudCBoYXMgbG9uZyBiZWVuIGFmb290IHRvIGJyaW5nIGEgdXNlZnVsIHBhY2th
Z2UgbWFuYWdlbWVudCBzeXN0ZW0gdG8gV2luZG93cy4gSWYgeW91J3ZlIHVzZWQgX19hcHRfXyBv
ciBfX3l1bV9fIG9yIF9feWFzdF9fIG9yIHNvbWUgc2ltaWxhciB0b29sIGluIGEgTGludXggZGlz
dHJpYnV0aW9uLCB0aGVuIHlvdSBrbm93IGhvdyBlYXN5IGl0IGNhbiBiZSB0byBpbnN0YWxsIG5l
dyBzb2Z0d2FyZSB0byB5b3VyIGNvbXB1dGVyIHdpdGggdGhlIHJpZ2h0IHV0aWxpdHkuIEVudGVy
IFsqY2hvY29sYXRleSwqXShodHRwOi8vY2hvY29sYXRleS5vcmcgImEgdGFzdHkgdHJlYXQiKSB0
aGUgUG93ZXJTaGVsbCBwYWNrYWdlIG1hbmFnZXIgZm9yIFdpbmRvd3MuPC9wPjxwPjxicj48L3A+
PHA+QmVmb3JlIHN0YXJ0aW5nIGEgbmV3IGNsYXNzIEkgbWFrZSBzdXJlIEkgbG9hZCB1cCBteSBp
bnN0cnVjdG9yIGNvbXB1dGVyIHdpdGggbXkgZmF2b3JpdGUgdGV4dCBlZGl0b3IgYW5kIG15IGNo
b3NlbiBmaWxlIG1hbmFnZXI6PC9wPjxwPjxicj48L3A+PHA+YGBgPC9wPjxwPmNob2NvIGluc3Rh
bGwgLXkgdmltIGRvdWJsZWNtZDwvcD48cD5gYGA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yb3NvZnQgaXMgaW50ZXJlc3RlZCBpbiB1c2luZyBpdC4gV2UnbGwgc2VlLiBQZXJo
YXBzIG1hbmFnaW5nIHNvZnR3YXJlIGluIFdpbmRvd3Mgd2lsbCBzb29uIGJlIGFzIGVhc3kgYXMg
aXQgaXMgaW4gTGludXguPC9wPjxwPjxicj48L3A+PHA+QmVlIHNlZWluZyB5b3UuPC9wPg==">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-59437129425115995152015-08-31T09:00:00.000-05:002015-08-31T09:00:01.775-05:00Brushing Up Your vim<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=5943712942511599515">
<div style="margin: 0px 0px 1.2em !important;">
<em>vim</em> is a quirky, spartan, powerful text editor derived from the standard UNIX tool <em>vi.</em> If you’ve decided to learn to use it, or want to refresh your memory as to how it works, here are a couple of suggestions.</div>
<h3 id="use-it" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Use It</h3>
<div style="margin: 0px 0px 1.2em !important;">
Make <strong>vim</strong> your go-to editor for all your text processing needs. Use it in Linux. Run it <a href="http://www.vim.org/download.php#pc" title="vim for pc">on Windows.</a> Make yourself use it regularly and it will become familiar over time.</div>
<div style="margin: 0px 0px 1.2em !important;">
<em>P.S.: I write all my PowerShell scripts in the Windows version of <strong>vim</strong>. More on this later.</em></div>
<h3 id="play-it" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Play It</h3>
<div style="margin: 0px 0px 1.2em !important;">
<a href="http://vim-adventures.com/" title="not Mavis Beacon">This lovely website</a> provides you with hours of entertainment playing a cool game while you learn and internalize the basics of working in <strong>vim</strong>. As you master the skills needed to defeat the game you’re also becoming adept at handling this most interesting of text editors.</div>
<div style="margin: 0px 0px 1.2em !important;">
I plan to speak more of <strong>vim</strong> in the coming weeks, so stay tuned. Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+KnZpbSogaXMgYSBxdWlya3ksIHNwYXJ0YW4sIHBvd2VyZnVsIHRleHQgZWRpdG9yIGRlcml2
ZWQgZnJvbSB0aGUgc3RhbmRhcmQgVU5JWCB0b29sICp2aS4qIElmIHlvdSd2ZSBkZWNpZGVkIHRv
IGxlYXJuIHRvIHVzZSBpdCwgb3Igd2FudCB0byByZWZyZXNoIHlvdXIgbWVtb3J5IGFzIHRvIGhv
dyBpdCB3b3JrcywgaGVyZSBhcmUgYSBjb3VwbGUgb2Ygc3VnZ2VzdGlvbnMuPC9wPjxwPjxicj48
L3A+PHA+IyMjIFVzZSBJdDwvcD48cD48YnI+PC9wPjxwPk1ha2UgX192aW1fXyB5b3VyIGdvLXRv
IGVkaXRvciBmb3IgYWxsIHlvdXIgdGV4dCBwcm9jZXNzaW5nIG5lZWRzLiBVc2UgaXQgaW4gTGlu
dXguICZuYnNwO1J1biBpdCBbb24gV2luZG93cy5dKGh0dHA6Ly93d3cudmltLm9yZy9kb3dubG9h
ZC5waHAjcGMgInZpbSBmb3IgcGMiKSBNYWtlIHlvdXJzZWxmIHVzZSBpdCByZWd1bGFybHkgYW5k
IGl0IHdpbGwgYmVjb21lIGZhbWlsaWFyIG92ZXIgdGltZS48L3A+PHA+PGJyPjwvcD48cD4qUC5T
LjogSSB3cml0ZSBhbGwgbXkgUG93ZXJTaGVsbCBzY3JpcHRzIGluIHRoZSBXaW5kb3dzIHZlcnNp
b24gb2YgX192aW1fXy4gJm5ic3A7TW9yZSBvbiB0aGlzIGxhdGVyLio8L3A+PHA+PGJyPjwvcD48
cD4jIyMgUGxheSBJdDwvcD48cD48YnI+PC9wPjxwPltUaGlzIGxvdmVseSB3ZWJzaXRlXShodHRw
Oi8vdmltLWFkdmVudHVyZXMuY29tLyAibm90IE1hdmlzIEJlYWNvbiIpIHByb3ZpZGVzIHlvdSB3
aXRoIGhvdXJzIG9mIGVudGVydGFpbm1lbnQgcGxheWluZyBhIGNvb2wgZ2FtZSB3aGlsZSB5b3Ug
bGVhcm4gYW5kIGludGVybmFsaXplIHRoZSBiYXNpY3Mgb2Ygd29ya2luZyBpbiBfX3ZpbV9fLiBB
cyB5b3UgbWFzdGVyIHRoZSBza2lsbHMgbmVlZGVkIHRvIGRlZmVhdCB0aGUgZ2FtZSB5b3UncmUg
YWxzbyBiZWNvbWluZyBhZGVwdCBhdCBoYW5kbGluZyB0aGlzIG1vc3QgaW50ZXJlc3Rpbmcgb2Yg
dGV4dCBlZGl0b3JzLjwvcD48cD48YnI+PC9wPjxwPkkgcGxhbiB0byBzcGVhayBtb3JlIG9mIF9f
dmltX18gaW4gdGhlIGNvbWluZyB3ZWVrcywgc28gc3RheSB0dW5lZC4gQmUgc2VlaW5nIHlvdS48
L3A+">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-54779315816642387982015-08-25T11:07:00.000-05:002017-10-17T10:31:20.932-05:00xargs: Praise the Lord and Pass the Argument!<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=5477931581664238798;onPublishedMenu=allposts;onClosedMenu=allposts;postNum=8;src=link" style="font-family: Charter,Georgia,Times New Roman,serif; font-size: 110%; line-height: 140%;">
<div style="margin: 0px 0px 1.2em !important;">
One interesting command in UNIX is the little <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">xargs</code> command. It takes something from standard input and passes it as an argument to another command. For example, if a command expects a user name, you can get that name from somewhere and feed it to the command through <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">xargs</code>:</div>
<pre style="font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">whoami | xargs passwd
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
The silly example above is also superfluous—<code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">passwd</code> can accept a user name through standard input directly, so xargs isn’t needed here. And of course, <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">passwd</code> with no arguments would change the current user’s password anyway. But it is a simple way to illustrate what <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">xargs</code> does. Some commands <em>don’t</em> look for a required argument in the standard input stream, so they won’t read directly from the pipe. <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">xargs</code> takes whatever is in the pipe and sends it as an argument to the command that follows; in this case, <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">passwd</code>.</div>
<div style="margin: 0px 0px 1.2em !important;">
I personally use <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">xargs</code> in my <strong>.xinitrc</strong> file to set a random background wallpaper on my desktop when I start X:</div>
<pre style="font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">find ~/pictures/wallpapers -type f | sort -R | tail -1 | xargs feh --bg-fill
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
The <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">find</code> command locates all the files in my wallpapers directory. The <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">sort</code> command puts the file names in random order and the <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">tail</code> command grabs only the last one in the list. <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">xargs</code> then passes that to <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Source Code Pro,Consolas,Inconsolata,Courier,monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">feh</code>, an image display utility, which sets the randomly selected file as my wallpaper. And so X greets me with a surprise every time I go GUI.</div>
<div style="margin: 0px 0px 1.2em !important;">
Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+T25lIGludGVyZXN0aW5nIGNvbW1hbmQgaW4gVU5JWCBpcyB0aGUgbGl0dGxlIGB4YXJnc2Ag
Y29tbWFuZC4gSXQgdGFrZXMgc29tZXRoaW5nIGZyb20gc3RhbmRhcmQgaW5wdXQgYW5kIHBhc3Nl
cyBpdCBhcyBhbiBhcmd1bWVudCB0byBhbm90aGVyIGNvbW1hbmQuIEZvciBleGFtcGxlLCBpZiBh
IGNvbW1hbmQgZXhwZWN0cyBhIHVzZXIgbmFtZSwgeW91IGNhbiBnZXQgdGhhdCBuYW1lIGZyb20g
c29tZXdoZXJlIGFuZCBmZWVkIGl0IHRvIHRoZSBjb21tYW5kIHRocm91Z2ggYHhhcmdzYDo8L3A+
PHA+PGJyPjwvcD48cD5gYGA8L3A+PHA+d2hvYW1pIHwgeGFyZ3MgcGFzc3dkPC9wPjxwPmBgYDwv
cD48cD48YnI+PC9wPjxwPlRoZSBzaWxseSBleGFtcGxlIGFib3ZlIGl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uZCBsb2NhdGVzIGFsbCB0aGUgZmlsZXMgaW4gbXkg
d2FsbHBhcGVycyBkaXJlY3RvcnkuIFRoZSBgc29ydGAgY29tbWFuZCBwdXRzIHRoZSBmaWxlIG5h
bWVzIGluIHJhbmRvbSBvcmRlciBhbmQgdGhlIGB0YWlsYCBjb21tYW5kIGdyYWJzIG9ubHkgdGhl
IGxhc3Qgb25lIGluIHRoZSBsaXN0LiBgeGFyZ3NgIHRoZW4gcGFzc2VzIHRoYXQgdG8gYGZlaGAs
IGFuIGltYWdlIGRpc3BsYXkgdXRpbGl0eSwgd2hpY2ggc2V0cyB0aGUgcmFuZG9tbHkgc2VsZWN0
ZWQgZmlsZSBhcyBteSB3YWxscGFwZXIuIEFuZCBzbyBYIGdyZWV0cyBtZSB3aXRoIGEgc3VycHJp
c2UgZXZlcnkgdGltZSBJIGdvIEdVSS48L3A+PHA+PGJyPjwvcD48cD5CZSBzZWVpbmcgeW91Ljwv
cD4=">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-86064516807181725812015-08-21T11:37:00.001-05:002015-08-21T11:38:21.735-05:00PowerShell: Set Multiple Variables at Once<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=8606451680718172581">
<div style="margin: 0px 0px 1.2em !important;">
A list of variable names can be an <em>l-value,</em> that is, an expression that appears on the left side of an assignment operator. Did you know that you could do this…</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">PS C:\> $FirstName, $Initial, $LastName = 'John', 'Q', 'Public'
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
This statement will assign each variable the corresponding value on the right of the assignment operator. What if the number of variable names and values doesn’t match? Extra values will be stored as an array in the last variable, so in</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">PS C:\> $FirstName, $Initial, $LastName = 'John', 'Q', 'Public', 'Sr', 'Esq'
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
that <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">$LastName</code> variable will be a list containing <strong>Public, Sr,</strong> and <strong>Esq.</strong> If there aren’t enough values, the extra variable names are unassigned.</div>
<div style="margin: 0px 0px 1.2em !important;">
Oh, and if you want to set several variable names to <em>the same value,</em> use this:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">PS C:\> $a = $b = $c = $d = 90
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Have fun with your variables. Be seeing you.</div>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EuX18g
SWYgdGhlcmUgYXJlbid0IGVub3VnaCB2YWx1ZXMsIHRoZSBleHRyYSB2YXJpYWJsZSBuYW1lcyBh
cmUgdW5hc3NpZ25lZC48L3A+PHA+PGJyPjwvcD48cD5PaCwgYW5kIGlmIHlvdSB3YW50IHRvIHNl
dCBzZXZlcmFsIHZhcmlhYmxlIG5hbWVzIHRvICp0aGUgc2FtZSB2YWx1ZSwqIHVzZSB0aGlzOjwv
cD48cD48YnI+PC9wPjxwPmBgYDwvcD48cD5QUyBDOlwmZ3Q7ICRhID0gJGIgPSAkYyA9ICRkID0g
OTA8L3A+PHA+YGBgPC9wPjxwPjxicj48L3A+PHA+SGF2ZSBmdW4gd2l0aCB5b3VyIHZhcmlhYmxl
cy4gQmUgc2VlaW5nIHlvdS48L3A+">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-88651965277009839182015-08-17T16:00:00.000-05:002015-08-17T16:00:14.399-05:00PowerShell - Microsoft's Trident: Part 3, Scripting<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=8865196527700983918;onPublishedMenu=allposts;onClosedMenu=allposts;postNum=4;src=link">
<h1 id="powershell-and-programming" style="border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.6em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
PowerShell and Programming</h1>
<div style="margin: 0px 0px 1.2em !important;">
I’ve been examining the three facets of PowerShell that make it such a powerful and useful tool in the hands of the Windows system admin. In this <a href="http://mechatechzilla.blogspot.com/2015/07/powershell-microsofts-trident-shell.html" title="Not King Neptune's conch">first post</a> I talked about the shell and its ability to plumb the depths of .NET. In the <a href="http://mechatechzilla.blogspot.com/2015/08/powershell-microsofts-trident-part-2.html" title="cmdlets are cool">second post</a> I discussed what makes cmdlets so cool and why every kid should want one. In this post we round out our look with…</div>
<h2 id="the-language-of-powershell" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
The Language of PowerShell</h2>
<div style="margin: 0px 0px 1.2em !important;">
Yes, even though it <em>is</em> a shell environment and it <em>has</em> a passel of useful cmdlets, it is also a rich programming (well, scripting) language. If you’ve ever written code in Assembler, C, FORTRAN, BASIC, Java or the like, you can appreciate all the goodness that PowerShell as a <em>language</em> has to offer.</div>
<h3 id="1-functions" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
1. Functions</h3>
<div style="margin: 0px 0px 1.2em !important;">
<em>Code reuse</em> is a term that gets tossed about in programming circles, but all that it means is to write and debug your code one time and use it over and over again. Not only does this prevent you from “re-inventing the wheel” but it makes your work easier to maintain. Once you know something works you just keep using it.</div>
<div style="margin: 0px 0px 1.2em !important;">
To that end PowerShell supports <em>functions,</em> blocks of PowerShell code that can be referred to by name. They look something like this:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">function Say-Hello ([String] $Name = 'Anonymous') {
Write-Host -NoNewLine 'Hello, '
Write-Host -ForegroundColor Cyan -NoNewLine $Name
Write-Host '.'
}
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
This creates a silly little function named <strong>Say-Hello</strong> that does just that, but in color. However, once we tweak this function to get it to work just the way we want it, all we have to do is call it:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">Say-Hello Dave
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Now we can drop this function call in anywhere we want to, as long as the function has been defined. Of course, if we want to use it in multiple scripts we really don’t want to have to copy and paste the function into all of them, so that brings us to…</div>
<h3 id="2-libraries" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
2. Libraries</h3>
<div style="margin: 0px 0px 1.2em !important;">
Libraries are files, PowerShell scripts, that generally contain nothing but definitions: variables and aliases sometimes, but mostly functions. When your script uses a library it can inherit all the names that were defined in that library. Libraries make it easy to write portable functions that may be used <em>anywhere,</em> and that’s what code reuse is all about.</div>
<div style="margin: 0px 0px 1.2em !important;">
PowerShell supports two different mechanisms for using libraries. You can load any PowerShell script into another using the <em>dot</em> operator to “source” the file, just like you can in UNIX shells:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">. $HOME/myScriptsDir/myLibrary.ps1
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Note the space after the dot, because it <em>is</em> a command.</div>
<div style="margin: 0px 0px 1.2em !important;">
If the library has been saved as a <em>module,</em> that is, with a <strong>.psm1</strong> extension, it can be managed through PowerShell’s module system and loaded with a cmdlet:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">Import-Module $HOME/myScriptsDir/myLibrary.psm1
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Modules and dot-sourced scripts each have a place, but both allow you to create libraries of useful functions and easily use them over and over again.</div>
<h3 id="3-flow-control" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
3. Flow Control</h3>
<div style="margin: 0px 0px 1.2em !important;">
Any programming or scripting language is arguably only as strong as its support for <em>flow control,</em> the ability to suddenly change direction at run time when the situation demands it. PowerShell has several tools for creating scripts that can respond to changing circumstances.</div>
<ul style="margin: 1.2em 0px; padding-left: 2em;">
<li style="margin: 0.5em 0px;"><div style="margin: 0.5em 0px !important; margin: 0px 0px 1.2em !important;">
<strong>Comparison Operators</strong><br />PowerShell contains a fairly rich set of comparison operators and can perform all kinds of tests to see if certain conditions have been met.</div>
</li>
<li style="margin: 0.5em 0px;"><div style="margin: 0.5em 0px !important; margin: 0px 0px 1.2em !important;">
<strong>Branching Constructs</strong><br />Sometimes you need a script to execute different instructions depending on some condition. PowerShell supports both <strong>if</strong> and <strong>switch</strong> keywords for branching to different parts of the script based on useful comparison results.</div>
</li>
<li style="margin: 0.5em 0px;"><div style="margin: 0.5em 0px !important; margin: 0px 0px 1.2em !important;">
<strong>Iteration</strong> (a.k.a, <em>Looping</em>)<br />PowerShell has five different looping constructs built in to the language, not to mention an iterative cmdlet. There are many ways to repeat tasks in PowerShell.</div>
</li>
</ul>
<h3 id="4-exception-handling" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
4. Exception Handling</h3>
<div style="margin: 0px 0px 1.2em !important;">
One of the beauties of PowerShell is that is has not one, but <em>two</em> mechanisms for exception handling. The <strong>trap</strong> keyword creates global error handlers that can be used to create a default behavior should any part of your script throw an exception. The <strong>try..catch</strong> construct can deal with errors at very specific parts of your script, giving you the flexibility to handle the same error in different ways depending on where in the execution it occurs.</div>
<div style="margin: 0px 0px 1.2em !important;">
These can each be used alone or combined together in the same script. Each has its strengths and addresses slightly different challenges for dealing with errors, but both give you the tools to ensure that exceptions are caught and dealt with in your PowerShell scripts.</div>
<hr />
<div style="margin: 0px 0px 1.2em !important;">
Really, PowerShell is a feature-rich language with first-class tools that allow you to write really useful administrative scripts. Of course, what would you expect from the company that brought BASIC to the <a href="http://en.wikipedia.org/wiki/Altair_8800" title="Still the one">Altair 8800?</a></div>
<div style="margin: 0px 0px 1.2em !important;">
Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+IyBQb3dlclNoZWxsIGFuZCBQcm9ncmFtbWluZzwvcD48cD48YnI+PC9wPjxwPkkndmUgYmVl
biBleGFtaW5pbmcgdGhlIHRocmVlIGZhY2V0cyBvZiBQb3dlclNoZWxsIHRoYXQgbWFrZSBpdCBz
dWNoIGEgcG93ZXJmdWwgYW5kIHVzZWZ1bCB0b29sIGluIHRoZSBoYW5kcyBvZiB0aGUgV2luZG93
cyBzeXN0ZW0gYWRtaW4uIEluIHRoaXMgW2ZpcnN0IHBvc3RdKGh0dHA6Ly9tZWNoYXRlY2h6aWxs
YS5ibG9nc3BvdC5jb20vMjAxNS8wNy9wb3dlcnNoZWxsLW1pY3Jvc29mdHMtdHJpZGVudC1zaGVs
bC5odG1sICJOb3QgS2luZyBOZXB0dW5lJ3MgY29uY2giKSBJIHRhbGtlZCBhYm91dCB0aGUgc2hl
bGwgYW5kIGl0cyBhYmlsaXR5IHRvIHBsdW1iIHRoZSBkZXB0aHMgb2Y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xsIHRoZSBvbmUiKTwvcD48cD48YnI+PC9wPjxw
PkJlIHNlZWluZyB5b3UuPC9wPg==">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-32277314049884309752015-08-07T10:02:00.000-05:002015-08-07T10:02:06.364-05:00Those Were (Not) the Days...<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=3227731404988430975">
<div style="margin: 0px 0px 1.2em !important;">
In my Linux and UNIX classes I introduce the students to a nifty little CLI tool called <strong>cal</strong>. Run from the command line, it displays a calendar of the current month with today highlighted. If you have a *nix terminal handy, fire it up and let’s take this little baby for a test drive.</div>
<div style="margin: 0px 0px 1.2em !important;">
Run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">cal</code> and you get the calendar for the current month. To see the calendar for the entire year, run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">cal 2015</code>.</div>
<div style="margin: 0px 0px 1.2em !important;">
You can also ask <strong>cal</strong> for a specific month and year. To find the date for Thanksgiving in the year 2020, run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">cal 11 2020</code>. Pass <strong>cal</strong> the month and year of your birth and you’ll see what day of the week was graced by that momentous occasion.</div>
<div style="margin: 0px 0px 1.2em !important;">
But do you want to see something cool? Run <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">cal 9 1752</code>. You might notice something wrong here—September of 1752 is missing eleven days! Is <strong>cal</strong> broken? Hardly. In September of 1752 the British Empire (finally) adopted the <a href="https://simple.wikipedia.org/wiki/Gregorian_calendar" title="Our modern calendar"><em>Gregorian calendar</em></a> to correct an error that was, by that time, eleven days long. What’s cool is that a little UNIX program already knew all that, so you don’t have to worry about accidentally scheduling a Tardis trip for London, September 8, 1752. That is, assuming the Tardis runs a version of UNIX…</div>
<div style="margin: 0px 0px 1.2em !important;">
So, there’s some trivia for the local pub. Perhaps you can use it to win a few drinks. And watch out for blue police call boxes.</div>
<div style="margin: 0px 0px 1.2em !important;">
Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+SW4gbXkgTGludXggYW5kIFVOSVggY2xhc3NlcyBJIGludHJvZHVjZSB0aGUgc3R1ZGVudHMg
dG8gYSBuaWZ0eSBsaXR0bGUgQ0xJIHRvb2wgY2FsbGVkIF9fY2FsX18uIFJ1biBmcm9tIHRoZSBj
b21tYW5kIGxpbmUsIGl0IGRpc3BsYXlzIGEgY2FsZW5kYXIgb2YgdGhlIGN1cnJlbnQgbW9udGgg
d2l0aCB0b2RheSBoaWdobGlnaHRlZC4gSWYgeW91IGhhdmUgYSAqbml4IHRlcm1pbmFsIGhhbmR5
LCBmaXJlIGl0IHVwIGFuZCBsZXQncyB0YWtlIHRoaXMgbGl0dGxlIGJhYnkgZm9yIGEgdGVzdCBk
cml2ZS48L3A+PHA+PGJyPjwvcD48cD5SdW4gYGNhbGAgYW5kIHlvdSBnZXQgdGhlIGNhbGVuZGFy
IGZvciB0aGUgY3VycmVudCBtb250aC4gVG8gc2VlIHRoZSBjYWxlbmRhciBmb3IgdGhlIGVudGly
ZSB5ZWFyLCBydW4gYGNhbCAyMDE1YC48L3A+PHA+PGJyPjwvc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JkaXMgdHJpcCBmb3IgTG9uZG9uLCBTZXB0ZW1iZXIgOCwg
MTc1Mi4gVGhhdCBpcywgYXNzdW1pbmcgdGhlIFRhcmRpcyBydW5zIGEgdmVyc2lvbiBvZiBVTklY
Li4uPC9wPjxwPjxicj48L3A+PHA+U28sIHRoZXJlJ3Mgc29tZSB0cml2aWEgZm9yIHRoZSBsb2Nh
bCBwdWIuIFBlcmhhcHMgeW91IGNhbiB1c2UgaXQgdG8gd2luIGEgZmV3IGRyaW5rcy4gQW5kIHdh
dGNoIG91dCBmb3IgYmx1ZSBwb2xpY2UgY2FsbCBib3hlcy48L3A+PHA+PGJyPjwvcD48cD5CZSBz
ZWVpbmcgeW91LjwvcD4=">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-16323651511011304262015-08-03T09:00:00.000-05:002015-08-03T09:00:02.279-05:00PowerShell - Microsoft's Trident: Part 2, Cmdlets<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=1632365151101130426;onPublishedMenu=posts;onClosedMenu=posts;postNum=2;src=link" markdown-here-wrapper-content-modified="true">
<h1 id="the-second-point-on-the-powershell-trident" style="border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.6em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
The Second Point on the PowerShell Trident</h1>
<div style="margin: 0px 0px 1.2em !important;">
In <a href="http://mechatechzilla.blogspot.com/2015/07/powershell-microsofts-trident-shell.html" title="The Shell">a previous post</a> I began to look at the three aspects of PowerShell that make it so powerful. In that first article I examined the shell itself, and how it can be used to do some really cool things. Now for the second point…</div>
<h2 id="cmdlets-k-mandlits-" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Cmdlets (/kəˈmandlits/)</h2>
<div style="margin: 0px 0px 1.2em !important;">
Cmdlets are wonderful things. As I stated in that last article, you <em>can</em> run just about any command in the PowerShell shell. But why would you? Between .NET (see that previous article) and the three-thousand-or-so cmdlets in PowerShell 3 and later, anything you need to do from the command line is taken care of. </div>
<div style="margin: 0px 0px 1.2em !important;">
Yes, initially there will be a bit of a learning curve, but it’s not nearly so bad as you might think, and the advantages far outweigh the inconvenience of learning something new. Besides, as a mentor of mine once said, “The day you stop learning is the day you start dying.” So let’s learn what makes cmdlets so cool.</div>
<h3 id="1-they-re-consistent-" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
1. They’re consistent.</h3>
<div style="margin: 0px 0px 1.2em !important;">
If you’ve used any command line environment in the past—CP/M, UNIX, DOS—one source of endless frustration is the lack of consistency among all those commands. “Can you use a space here? Are parameters prefixed with a slash, a dash, two dashes, or not at all? Are they case sensitive?” The very fact that one must even ask such questions makes learning to use the command line difficult and contributes to it’s bad reputation. </div>
<div style="margin: 0px 0px 1.2em !important;">
But really, it’s foolish to expect anything else. Each of those commands was written by different people at different times to solve different problems. Their authors each had his own experiences and way of thinking that affected how he would address his particular need. It’s only natural that those commands bear little resemblance to one another.</div>
<div style="margin: 0px 0px 1.2em !important;">
But then came the GUI. When Apple introduced the Lisa in the early eighties it also published a style guide so that developers could write programs that correspond to the system’s look and feel. Microsoft did the same when Windows was released some years later. Building on that experience, Microsoft has provided some <a href="https://technet.microsoft.com/en-us/%5Clibrary/Dd878270(v=VS.85).aspx" title="Design Guide">recommendations</a> for developers of new cmdlets so that users don’t have to face the arduous task of learning a new set of commands from scratch. In theory, once you learn how to use one cmdlet you can apply that knowledge to any cmdlet. In practice, it works really well.</div>
<h3 id="2-they-re-well-documented-" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
2. They’re well-documented.</h3>
<div style="margin: 0px 0px 1.2em !important;">
Referring to those operating systems previously mentioned: help in CP/M was non-existent; in DOS it was terse and sometimes cryptic; and while often useful and informative in UNIX the man pages for commands are as diverse and inconsistent as the commands themselves. When a user has to toil by the sweat of his brow to unearth a little information, it’s little wonder that he would run the other way rather than learn how a command works.</div>
<div style="margin: 0px 0px 1.2em !important;">
PowerShell, though, is actually helpful. The <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">Get-Help</code> cmdlet provides different levels of verbosity, from printing out basic syntax to highlighting every detail of each argument that a cmdlet will accept. It can even display working examples of how a cmdlet is used, which fits my learning style perfectly. You can also search through the help using the standard shell wildcard characters <strong><code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">*</code></strong> and <strong><code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">?</code></strong>. </div>
<div style="margin: 0px 0px 1.2em !important;">
And it’s thorough. Not only can you find information on cmdlets, but concepts are documented as well. Try <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">Get-Help about_arithmetic_operators</code> to find out how PowerShell does math, or <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">Get-Help about_if</code> to review how PowerShell makes decisions. If you need to know something about PowerShell, like Prego spaghetti sauce, “It’s in there.”</div>
<h3 id="3-they-return-objects-" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
3. They return objects.</h3>
<div style="margin: 0px 0px 1.2em !important;">
One of the things that makes it difficult to use command line tools is that they go about their business, perhaps print something on the screen, and leave. This is fine if you happen to be hanging about to read the output, but makes things tough if you want to automate some task in a script. The problem is one of parsing.</div>
<div style="margin: 0px 0px 1.2em !important;">
Let’s say that I want to fetch a computer’s IP address from DNS and use that address in some other process. I can use:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">nslookup www.centriq.com
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Since I can see the result on screen, I can parse the output, find the relevant data, and do what I want to with it. Humans are good at this sort of thing; computers, not so much. Let’s try to fetch just the IP address in <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">cmd.exe</code> with some fancier command-fu:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">set host=www.centriq.com
for /f "usebackq tokens=2" %%i in (`nslookup %host%`) do set ipaddr=%%i
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Now I have a variable called <strong>ipaddr</strong> that contains the IPv4 address of <strong>host</strong>, right? Well, maybe. The problem is that <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">nslookup</code> changes its output depending on the information in the DNS record it queries. This command expects the data of interest to be on the last line of output, which will work much of the time, but not always. </div>
<div style="margin: 0px 0px 1.2em !important;">
Compare that to the following:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">$host = 'www.centriq.com'
$ipaddr = resolve-dnsname $host | ? ip4address | select -expand ip4address
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
If an A record for <strong>host</strong> exists, the <strong>ipaddr</strong> variable will <em>always</em> contain an IPv4 address. No doubt about it, and no parsing necessary. The object that PowerShell creates from the <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">Resolve-DNSName</code> cmdlet will have an IP address property that we can directly query and save in a variable.</div>
<div style="margin: 0px 0px 1.2em !important;">
In fact, all of those objects have useful properties and methods that we can use to customize the output of a cmdlet or even change the state of a computer. These objects can start services, kill processes, change passwords, and so on. They are infinitely more useful than a few lines of text output upon a computer screen. </div>
<hr />
<div style="margin: 0px 0px 1.2em !important;">
If you’ve ever found the command line infuriating don’t let that stop you from learning how to get what you want from PowerShell. Its cmdlets were designed to address the very frustrations you’ve had with other shells. While learning this new system will require an investment of time and effort, the dividends are definitely worth it.</div>
<div style="margin: 0px 0px 1.2em !important;">
Stay tuned for part three of this series. Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PGRpdj4jIFRoZSBTZWNvbmQgUG9pbnQgb24gdGhlIFBvd2VyU2hlbGwgVHJpZGVudDwvZGl2Pjxk
aXY+PGJyPjwvZGl2PjxkaXY+SW4gW2EgcHJldmlvdXMgcG9zdF0oaHR0cDovL21lY2hhdGVjaHpp
bGxhLmJsb2dzcG90LmNvbS8yMDE1LzA3L3Bvd2Vyc2hlbGwtbWljcm9zb2Z0cy10cmlkZW50LXNo
ZWxsLmh0bWwgIlRoZSBTaGVsbCIpIEkgYmVnYW4gdG8gbG9vayBhdCB0aGUgdGhyZWUgYXNwZWN0
cyBvZiBQb3dlclNoZWxsIHRoYXQgbWFrZSBpdCBzbyBwb3dlcmZ1bC4gSW4gdGhhdCBmaXJzdCBh
cnRpY2xlIEkgZXhhbWluZWQgdGhlIHNoZWxsIGl0c2VsZiwgYW5kIGhvdyBpdCBjYW4gYmUgdXNl
ZCB0byBkbyBzb21lIHJlYWxseSBjb29sIHRoaW5ncy4gTm93IGZvciB0aGUgc2Vjb25kIHBvaW50
Li4uPC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj4jIyBDbWRsZXRzICgva8mZy4htYW5kbGl0cy8p
PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5DbWRsZXRzIGFyZSB3b25kZXJmdWwgdGhpbmdzLiBB
cyBJIHN0YXRlZCBpbiB0aGF0IGxhc3QgYXJ0aWNsZSwgeW91ICpjYW4qIHJ1biBqdXN0IGFib3V0
IGFueSBjb21tYW5kIGluIHRoZSBQb3dlclNoZWxsIHNoZWxsLiBCdXQgd2h5IH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gdG8g
YWRkcmVzcyB0aGUgdmVyeSBmcnVzdHJhdGlvbnMgeW91J3ZlIGhhZCB3aXRoIG90aGVyIHNoZWxs
cy4gV2hpbGUgbGVhcm5pbmcgdGhpcyBuZXcgc3lzdGVtIHdpbGwgcmVxdWlyZSBhbiBpbnZlc3Rt
ZW50IG9mIHRpbWUgYW5kIGVmZm9ydCwgdGhlIGRpdmlkZW5kcyBhcmUgZGVmaW5pdGVseSB3b3J0
aCBpdC48L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PlN0YXkgdHVuZWQgZm9yIHBhcnQgdGhyZWUg
b2YgdGhpcyBzZXJpZXMuIEJlIHNlZWluZyB5b3UuPC9kaXY+">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-91990213368602959282015-07-30T09:58:00.000-05:002015-07-30T09:59:14.194-05:00PowerShell(s) of Two<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=9199021336860295928">
<div style="margin: 0px 0px 1.2em !important;">
While writing out some IP addressing exercises I needed a quick reminder of some of the powers of 2 that I use a little less frequently. I just opened up a PowerShell console and made a little table like this:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">foreach ($i in 0..32) {"{0,8} {1,-11}" -f $i, ([System.Math]::Pow(2, $i))}
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Hope you find this useful. Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+V2hpbGUgd3JpdGluZyBvdXQgc29tZSBJUCBhZGRyZXNzaW5nIGV4ZXJjaXNlcyBJIG5lZWRl
ZCBhIHF1aWNrIHJlbWluZGVyIG9mIHNvbWUgb2YgdGhlIHBvd2VycyBvZiAyIHRoYXQgSSB1c2Ug
YSBsaXR0bGUgbGVzcyBmcmVxdWVudGx5LiBJIGp1c3Qgb3BlbmVkIHVwIGEgUG93ZXJTaGVsbCBj
b25zb2xlIGFuZCBtYWRlIGEgbGl0dGxlIHRhYmxlIGxpa2UgdGhpczo8L3A+PHA+PGJyPjwvcD48
cD4mbmJzcDsgJm5ic3A7IGZvcmVhY2ggKCRpIGluIDAuLjMyKSB7InswLDh9IHsxLC0xMX0iIC1m
ICRpLCAoW1N5c3RlbS5NYXRoXTo6UG93KDIsICRpKSl9PC9wPjxwPjxicj48L3A+PHA+SG9wZSB5
b3UgZmluZCB0aGlzIHVzZWZ1bC4gQmUgc2VlaW5nIHlvdS48L3A+">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-3827993607114735122015-07-28T11:58:00.003-05:002015-07-28T15:22:13.242-05:00PowerShell - Microsoft's Trident: Part 1, the Shell<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=382799360711473512">
<h1 id="the-three-tines-of-powershell" style="border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.6em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
The Three Tines of PowerShell</h1>
<div style="margin: 0px 0px 1.2em !important;">
Like the powerful trident in the hands of Poseidon, PowerShell can be wielded for good or ill. It can create vast wellsprings of new possibilities for the savvy administrator and unleash destructive floods of complexity on the uninitiated. To some it solves many problems, to others it is the source of many headaches.</div>
<div style="margin: 0px 0px 1.2em !important;">
What I want to examine now, though, is the triune nature of this beast. Like Poseidon’s legendary weapon, PowerShell takes a three-pronged poke at the issues that commonly beset us in IT.</div>
<h2 id="the-shell" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
The Shell</h2>
<div style="margin: 0px 0px 1.2em !important;">
PowerShell is a shell. That is, it’s an environment in which you can type commands to get your computer to do something. But it’s a <em>really cool</em> shell.</div>
<h3 id="1-it-gives-you-direct-access-to-net-" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
1. It gives you direct access to .NET.</h3>
<div style="margin: 0px 0px 1.2em !important;">
I can’t stress this enough. .NET. From the command line. At your fingertips at all times, ready to do your bidding. If there is <em>anything</em> you must know about PowerShell, it is this. Almost anything that can be done in .NET can be done from the command line in PowerShell. Do you want to get data from a web server? </div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">[System.Net.WebRequest]::Create('http://www.mysite.com/index.html')
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Do you want to place the cursor somewhere particular on the screen? </div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">$Host.UI.RawUI.CursorPosition = @{x = 20; y = 47}
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
I’m talking about some cool stuff. For example, Microsoft failed to give us an equivalent to the DOS ‘pause’ command in the initial release of PowerShell, and their eventual addition of a comparable function is lame. That’s because PowerShell can’t respond when you “Press any key to continue…” It doesn’t know you’ve pressed a key until you hit Enter and send to it the contents of the keyboard buffer. But .NET can access the keyboard at a lower level, bypassing the buffer:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">function Wait-Key {
<#
.SYNOPSIS
Prompts the user to press a key and waits until the user does so.
.DESCRIPTION
The Wait-Key function simulates the DOS program pause. It gives a script an
opportunity to wait for the user to press a key before proceeding.
.PARAMETER Message
The prompt message to display when the script pauses.
#>
[CmdletBinding()] param (
[string] $Message = "Press any key to continue..."
)
$Message
$Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown") | Out-Null
} # end function Wait-Key
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
With .NET and the <a href="https://msdn.microsoft.com/library" title="MSDN Reference Library">MSDN website</a> at your beck and call your command-fu is only limited by your imagination.</div>
<h3 id="2-it-allows-you-to-run-any-command-" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
2. It allows you to run any command.*</h3>
<div style="margin: 0px 0px 1.2em !important;">
From PowerShell you can launch any graphical program. Open up a text file in notepad or an html report in your default web browser.</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">notepad .\seating_chart.txt
Invoke-Expression ./disk_report.html
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
You can run any command-line utility…</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">ipconfig /displaydns
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
… even old CLI tools whose arcane syntax can cause PowerShell to balk—when you use the <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">--%</code> operator between the command and it’s arguments.</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">ICACLS.EXE --% C:\TEST /GRANT USERS:(F)
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
<em>* Okay, so not really ANY command. You can’t run commands that are built in to the old CMD.EXE or COMMAND.COM command shells. This makes sense, as those commands are not stand-alone tools but are BUILT-IN. That’s why there’s point number 3.</em></div>
<h3 id="3-powershell-has-cool-aliases-for-useful-commands-" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
3. PowerShell has cool aliases for useful commands.</h3>
<div style="margin: 0px 0px 1.2em !important;">
As stated in the caveat above, CMD.EXE had several commands integrated into the shell itself. There are no executables for DIR or CD or DEL, so you can’t get at those from PowerShell. However, Microsoft has borrowed a page from other shells and given us aliases. While not quite as useful as the UNIX implementation of the concept they do allow us to create familiar or shortened names for common commands. So I can type <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">DIR</code>—or <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">ls</code> for that matter—and get a directory listing. Granted, what I get is <em>not</em> the result of <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">DIR</code> but the PowerShell <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">Get-ChildItem</code> command, so things are a little different, but not completely alien. I can easily create aliases of my own, if I like:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">Set-Alias -Name unlink -Value Remove-Item
Set-Alias -Name goto -Value Set-Location
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
With aliases I can customize the shell to suit the way I prefer to work. To me, that makes PowerShell the best Windows shell around.</div>
<hr />
<div style="margin: 0px 0px 1.2em !important;">
So stop using that old command interpreter. PowerShell is a much better shell than anything Microsoft has given us before, and with it we can do so much more than CMD will allow. And stay tuned for the other two prongs in the PowerShell trident.<br />
<br />
Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+I1RoZSBUaHJlZSBUaW5lcyBvZiBQb3dlclNoZWxsPC9wPjxwPjxicj48L3A+PHA+TGlrZSB0
aGUgcG93ZXJmdWwgdHJpZGVudCBpbiB0aGUgaGFuZHMgb2YgUG9zZWlkb24sIFBvd2VyU2hlbGwg
Y2FuIGJlIHdpZWxkZWQgZm9yIGdvb2Qgb3IgaWxsLiBJdCBjYW4gY3JlYXRlIHZhc3Qgd2VsbHNw
cmluZ3Mgb2YgbmV3IHBvc3NpYmlsaXRpZXMgZm9yIHRoZSBzYXZ2eSBhZG1pbmlzdHJhdG9yIGFu
ZCB1bmxlYXNoIGRlc3RydWN0aXZlIGZsb29kcyBvZiBjb21wbGV4aXR5IG9uIHRoZSB1bmluaXRp
YXRlZC4gVG8gc29tZSBpdCBzb2x2ZXMgbWFueSBwcm9ibGVtcywgdG8gb3RoZXJzIGl0IGlzIHRo
ZSBzb3VyY2Ugb2YgbWFueSBoZWFkYWNoZXMuPC9wPjxwPjxicj48L3A+PHA+V2hhdCBJIHdhbnQg
dG8gZXhh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2Rpdj48ZGl2Pjxicj48L2Rpdj4=">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-72071384381071154662014-08-11T08:16:00.000-05:002015-08-29T18:23:43.608-05:00Express Yourself, Regularly<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=7207138438107115466;onPublishedMenu=posts;onClosedMenu=posts;postNum=10;src=link">
<h1 id="the-basics-of-regular-expressions" style="border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.6em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
The Basics of Regular Expressions</h1>
<h2 id="introduction" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Introduction</h2>
<div style="margin: 0px 0px 1.2em !important;">
Unix administrators have long used regular expressions to help them locate files, modify data, and manage system configurations. Tools like <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">grep</code> and <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">sed</code> are designed to process regular expressions to provide the administrator with exactly the information he wants. While versions of these tools have been ported to Windows, most Windows administrators are unaware that they exist. Because of the limitations of the Windows command shell, Windows administrators typically stick with slower, more complicated graphical tools to manage the operating system.</div>
<div style="margin: 0px 0px 1.2em !important;">
Enter PowerShell. PowerShell is designed to be a replacement for the standard Windows shell, and it is far more powerful and flexible than its predecessor. Among the many command enhancements PowerShell offers is built-in support for regular expressions. It borrows this capability heavily from <a href="http://perldoc.perl.org/perlintro.html#What-is-Perl%3f">Perl</a>, a scripting language that was developed specifically for processing text.</div>
<div style="margin: 0px 0px 1.2em !important;">
Regular expressions are used to search for character sequences inside text strings or files. Programs that process regular expressions look for text that matches a given pattern. The components of a regular expression are not complicated, but the available combinations are many and varied, making it possible to perform some very sophisticated matches. Whether you’re administering Windows, Linux, or the Unix-based Mac OS X, you should invest some time learning the cryptic syntax of regular expressions so that you can manage systems and automate common tasks.</div>
<div style="margin: 0px 0px 1.2em !important;">
This tutorial will introduce regular expressions. It is not aimed at a particular operating system. Students of both Linux and PowerShell will come away with a basic knowledge of how regular expressions work and how to craft their own. Specific tools such as Linux’s <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">grep</code> command and PowerShell’s <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">-match</code> operator are covered in those respective classes at <a href="http://www.centriq.com/">Centriq Training</a>. </div>
<h2 id="overview" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Overview</h2>
<div style="margin: 0px 0px 1.2em !important;">
Whenever we begin to learn a new technology we get excited about the possibilities. We catch a glimpse of all kinds of nifty things that we can do with this knowledge. We often forget, though, that each technology has its limitations. Regular expressions are cool and powerful and flexible and a lot of other things, but there are some things that they’re not—some things that they cannot do. Like all things new, regular expressions come with a learning curve that is best overcome with practice. To avoid getting frustrated as you begin to learn regular expressions you must always keep three rules in mind.</div>
<h3 id="rule-1-regular-expressions-match-text-not-numbers-" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Rule 1. Regular expressions match text, not numbers.</h3>
<div style="margin: 0px 0px 1.2em !important;">
Regular expressions can represent any sequence of characters that you can find on a typical keyboard, and even some that you can’t, but they can’t express any other kind of data. They don’t understand numbers.</div>
<div style="margin: 0px 0px 1.2em !important;">
This confuses people at first, because regular expressions are frequently employed to determine things like whether a user’s input is a numeric age or zip code or year. But in these cases the regular expression is used to test the <em>characters</em> and ensure that they are numerals. The quantities that these numerals stand for are completely lost on the regular expression: it can’t identify a numeral’s value.</div>
<div style="margin: 0px 0px 1.2em !important;">
Remember, even numbers are written with characters. Regular expressions can be used to recognize those characters, but they can’t be used to determine their values, so they don’t work with actual numbers.</div>
<h3 id="rule-2-regular-expressions-are-made-from-three-components-characters-anchors-and-modifiers-" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Rule 2. Regular expressions are made from three components: characters, anchors, and modifiers.</h3>
<div style="margin: 0px 0px 1.2em !important;">
Every regular expression must have at least one character. This provides the basis for any match that will be performed. Anchors may be used to establish that the characters belong in certain positions in the text. Modifiers may be used to match repeated instances of a character or change a character’s meaning.</div>
<div style="margin: 0px 0px 1.2em !important;">
Characters are pretty simple, but the anchors and modifiers are what make regular expressions so powerful—and difficult to read. No matter how complex the expression, though, it always begins with at least one character.</div>
<h3 id="rule-3-each-program-is-a-little-different-" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Rule 3. Each program is a little different.</h3>
<div style="margin: 0px 0px 1.2em !important;">
There are many programs and programming languages that can process regular expressions. While there is a <a href="http://www.regular-expressions.info/posix.html">standard definition</a> of characters, anchors, and modifiers individual programs have sometimes extended and customized their definition of a regular expression. Generally, this is done to make expressions easier for us humans to use, but it can lead to confusion for the student who is just learning the syntax. In this tutorial I’m going to stick mostly with standard syntax, but at the end I’ll provide specific examples with grep and PowerShell.</div>
<div style="margin: 0px 0px 1.2em !important;">
So if you run across a regular expression that looks unusual or that doesn’t work in your specific tool, that doesn’t necessarily mean that it’s wrong. Each program is a little different.</div>
<h2 id="a-first-look-at-characters" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
A First Look at Characters</h2>
<div style="margin: 0px 0px 1.2em !important;">
The group of characters that make up a regular expression’s search string is called a pattern. Patterns can be very simple. For example, <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">d</code> is a valid pattern. It matches any string of text that contains a “d” character, like “Dave”, “dude”, or “all work and no play makes Jack a dull boy”. Whether the matching is case-sensitive depends on the processor that’s performing the match. Remember Rule 3: each program is a little different.</div>
<div style="margin: 0px 0px 1.2em !important;">
When it comes to matching characters, you should know that most regular expression processors are going to match only the first instance that they find. In that last string, the expression matches the “d” in “and”, but not the one in “dull.” Once a program finds the first match, it usually stops processing the string altogether.</div>
<div style="margin: 0px 0px 1.2em !important;">
Characters can be combined to make whole words or phrases. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">error</code> will match any string that contains the word “error” in any form. This includes “errors”, as well as other words like “terror”. Remember that the pattern you’re searching for is just a string of characters. If your pattern includes spaces or other special characters, you usually have to enclose it in quotation marks.</div>
<div style="margin: 0px 0px 1.2em !important;">
Sometimes we don’t want to match a particular character, just any character. For this we use a wildcard, which in regular expression syntax is a period. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">d.d</code> would match “dad”, “dude”, and “katydid”, because there must be exactly one character between the two d’s. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">d...d</code> will match “David”, “domed”, “android”, and even “my good buddy Steve” because in each case there are d’s separated by three characters. Note that in the last example those three characters include a space. That’s okay: a wildcard matches any character—even numerals, spaces, and punctuation marks.</div>
<h2 id="anchors-put-it-where-you-want-it" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Anchors Put It Where You Want It</h2>
<div style="margin: 0px 0px 1.2em !important;">
An anchor is a special character that ties a part of your pattern to the beginning or end of a text string. The caret symbol, <strong>^</strong>, can be created by pressing <strong>Shift-6</strong> on most US keyboards. It anchors a pattern to the beginning of a search string. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^car</code> will match “caret”, but not “lascar”. The caret symbol at the beginning of the pattern tells a regular expression processor that no character may precede the pattern.</div>
<div style="margin: 0px 0px 1.2em !important;">
The dollar symbol, <strong>$</strong>, can be created by pressing <strong>Shift-4</strong> on most US keyboards. It anchors the pattern to the end of a text string. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">ave$</code> will match “Dave” but not “avenue”. The dollar symbol at the end of the pattern tells the regular expression processor that no character may follow the pattern.</div>
<div style="margin: 0px 0px 1.2em !important;">
A pattern that includes both anchors can be used to search for an exact match of the pattern to the text string. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^error$</code> will exactly match the string “error”, but not “terror” or “errors”. It will not match a string that contains the word “error” among other things, like “error in module fuse.ko”—it is always an exact match.</div>
<div style="margin: 0px 0px 1.2em !important;">
Of course, you can combine wildcards with anchors. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^d...d$</code> will match “David” and “dared”, but not “android” or “dreaded”. And if you want to match on a blank line, you can use the pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^$</code>.</div>
<h2 id="expanding-a-pattern-with-modifiers" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Expanding a Pattern With Modifiers</h2>
<h3 id="the-great-escape" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
The Great Escape</h3>
<div style="margin: 0px 0px 1.2em !important;">
You’ve learned that, in regular expression syntax, a period is a wildcard. But sometimes we want to search for a literal period. Because the period stands for any character, the pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^169.254.</code> would match the IP address “169.254.14.2”, but it would also match the string “1698254a”, which is not what we’re looking for. What we want to do is modify the period and change its meaning.</div>
<div style="margin: 0px 0px 1.2em !important;">
The backslash character, <strong>\</strong>, is a special modifier called the “escape character”. It changes the meaning of the character that immediately follows it, “escaping” from the normal interpretation of the pattern. When it precedes a period, the backslash takes away the period’s meaning as a wildcard so that it becomes a normal period. So the pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^169\.254\.</code> will match “169.254.14.2” but not “1698254a”. Since the periods have been “escaped”, there are no wildcards in this pattern. Likewise, the pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^\$</code> will look for a string that begins with a dollar sign, and <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^4\^2$</code> will match a string that contains exactly “4^2”.</div>
<h3 id="time-and-time-again" style="font-size: 1.3em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Time and Time Again</h3>
<div style="margin: 0px 0px 1.2em !important;">
It is often necessary to look for a repeating number of characters in a text string. Multipliers allow you to extend your expression to include repetition in your searches. They are special characters that follow some other character in a pattern. They multiply the character that appears immediately before them by some value. There are several multipliers, so you’ll need to commit them to memory.</div>
<div style="margin: 0px 0px 1.2em !important;">
The question mark, <strong>?</strong>, can be produced on most US keyboards by pressing <strong>Shift-/</strong>. It multiplies the preceding character by zero or one. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^d.?d$</code> will match both “dd” and “did”, requiring zero or one characters between the d’s.</div>
<div style="margin: 0px 0px 1.2em !important;">
The asterisk, <strong>*</strong>, can be produced on most US keyboards by pressing <strong>Shift-8</strong>. The asterisk multiplies the preceding character by zero or more. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^d.*d$</code> will match “dd”, “did”, “dreamed”, and “drumming in your head”, because it allows any number of characters to exist between the d’s.</div>
<div style="margin: 0px 0px 1.2em !important;">
The plus symbol, <strong>+</strong>, can be produced on most US keyboards by pressing <strong>Shift-=</strong>. It multiplies the preceding character by one or more. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^d.+d$</code> matches “did”, “dreamed”, and “drumming in your head”, but it does not match “dd”. The plus symbol requires at least one character to appear between the d’s.</div>
<div style="margin: 0px 0px 1.2em !important;">
Advanced multiplication is not supported by all regular expression processors, and not consistently among those that do. Remember, each program is a little different. However, because many programs and programming languages support it to some extent you should get to know it and its variations.</div>
<div style="margin: 0px 0px 1.2em !important;">
Advanced multipliers contain values inside curly braces, the <strong>{</strong> and <strong>}</strong> characters. These can be produced on most US keyboards by pressing <strong>Shift-[</strong> and <strong>Shift-]</strong> respectively. </div>
<div style="margin: 0px 0px 1.2em !important;">
Placing a single value in the braces multiplies the preceding character by exactly that number. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^d.{3}d$</code> matches “David” and “druid”, requiring exactly three characters between the d’s. Note that this pattern could have been written <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^d...d$</code>, but as we learn about more characters we’ll see that the advanced multiplier can be much easier to read.</div>
<div style="margin: 0px 0px 1.2em !important;">
Enclosing two values separated by a comma within the braces, we get a specific range of multipliers. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^d.{3,5}d$</code> multiplies the wildcard by three, four, and five. It matches “druid”, “darned”, and “dreamed”, requiring three to five characters between the d’s.</div>
<div style="margin: 0px 0px 1.2em !important;">
If the braces contain a single number followed by a comma, the range of multipliers has no upper limit. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^d.{3,}d$</code> matches any string with three or more characters between the d’s.</div>
<h2 id="advanced-characters" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Advanced Characters</h2>
<div style="margin: 0px 0px 1.2em !important;">
There’s more to characters than literal symbols and wildcards. While the advanced characters may not look like single characters to you, to the regular expression processor they are indeed just a character. Sometimes these are called “meta-characters”, because they are a group of symbols that stand for a single character. Combined with multipliers, these meta-characters make it possible to create sophisticated searches.</div>
<div style="margin: 0px 0px 1.2em !important;">
Square brackets allow you to specify one from a group of characters that you want to match. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^d[aiu]d$</code> represents three characters. The symbols between the brackets are applied in turn to the search, so that this pattern matches “dad”, “did”, and “dud”. The pattern requires that there must be nothing but an a, i, or u between the d’s.</div>
<div style="margin: 0px 0px 1.2em !important;">
If you want to search for a string that begins with a vowel you can use the pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^[aeiou]</code>. You can negate the pattern with a caret symbol <em>inside</em> the brackets. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^[^aeiou]</code> matches all strings that begin with any character that is not a vowel. Don’t let the use of the caret confuse you. At the beginning of a pattern the caret is an anchor. Inside square brackets it reverses the meaning of the group. This could be read as “not a, e, i, o, or u”, so inside brackets the caret symbol means “not”.</div>
<div style="margin: 0px 0px 1.2em !important;">
The brackets can also contain a range, two values separated by a hyphen. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[0-9]</code> represents all numerals. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^169\.254\.[0-9]{1,3}\.[0-9]{1,3}$</code> uses escape sequences, ranges, and multipliers to match IP addresses that begin with “169.254.”.</div>
<div style="margin: 0px 0px 1.2em !important;">
Since a range of characters is just a character in regular expression syntax, ranges can be grouped. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^[0-9a-z]</code> will match all strings that begin with a numeral or a lowercase letter. Many shell scripts use the pound sign at the beginning of a line to identify comments. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">^[#a-zA-Z]</code> matches all the lines in a script that begin with a pound sign or a letter.</div>
<div style="margin: 0px 0px 1.2em !important;">
Many common character groups have special classes defined for them. The range <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[0-9]</code> can also be written using the class <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[:digit:]</code>. Other classes include <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[:alpha:]</code> for all letters, <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[:lower:]</code> for lowercase letters, <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[:upper:]</code> for uppercase letters, <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[:alnum:]</code> for letters and numbers, <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[:space:]</code> for white space characters like space and tab, <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[:cntrl:]</code> for non-printable control characters, and <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[:xdigit:]</code> for characters used to represent hexadecimal numbers, equivalent to <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">[0-9a-fA-F]</code>.</div>
<div style="margin: 0px 0px 1.2em !important;">
Some advanced regular expression processors such as those found in Perl and PowerShell can also use escape sequences to represent character classes. Some common ones are: <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">\d</code> to represent any digit; <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">\w</code> to represent any word character such as letters, numbers, and some punctuation; and <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">\s</code> to represent white space characters. A capital letter in the escape sequence negates it, so <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">\D</code> represents any character that is not a digit, and <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">\S</code> represents any character that is not white space.</div>
<div style="margin: 0px 0px 1.2em !important;">
Parentheses, <strong>(</strong> and <strong>)</strong>, can be produced on most US keyboards by pressing <strong>Shift-9</strong> and <strong>Shift-0</strong> respectively. They can be used to combine multiple patterns together. The pipe symbol, <strong>|</strong>, is produced by pressing <strong>Shift-\</strong> on most US keyboards. It ties together multiple patterns within the parentheses using “or” logic. The expression <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">(^[:digit:]{5}$ | ^[:digit:]{5}-[:digit:]{4}$)</code> contains two patterns, and will process a string until one pattern or the other matches some text. This regular expression matches a US zip code written in either the five-digit or five-plus-four-digit format, such as “02134” and “64119-4105”.</div>
<div style="margin: 0px 0px 1.2em !important;">
Finally come the angle brackets, <strong><</strong> and <strong>></strong>, which can be produced on most US keyboards by pressing <strong>Shift-,</strong> and <strong>Shift-.</strong> respectively. These identify word boundaries, so whatever is enclosed within is considered to be a whole word. The pattern <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">< error ></code> matches “error”, but not “errors” or “terror”. The angle brackets require that only white space or punctuation may appear on either side of the enclosed pattern.</div>
<div style="margin: 0px 0px 1.2em !important;">
Please note that many regular expression processors will require that curly braces and angle brackets be preceded by a backslash to escape them, otherwise they are treated as literal brackets. You may have to experiment or read your program’s documentation to determine what it will support.</div>
<h2 id="summary" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Summary</h2>
<div style="margin: 0px 0px 1.2em !important;">
Regular expressions consist of character patterns that are matched against text strings. Each pattern must contain at least one character, but its matching capabilities can be enhanced with anchors, modifiers, and advanced meta-characters.</div>
<div style="margin: 0px 0px 1.2em !important;">
Regular expression patterns can be written to match almost any kind of text, but they don’t assign any meaning to that text. A regular expression recognizes no numeric values, it doesn’t understand what to do with punctuation marks, and it’s limited to matching on one line of a file at a time. All that the pattern can represent is text characters.</div>
<div style="margin: 0px 0px 1.2em !important;">
Regular expression processors are programs and programming language constructs that use patterns to find and work with text. Some of these have very advanced capabilities, such as extending a search to include multiple lines of a file or performing pattern matches backward as well as forward on the text. The beginner will need to practice with each of the regular expression tools that he intends to use to gain an understanding of its features, but the fundamental concepts covered in this tutorial will be applicable.</div>
<div style="margin: 0px 0px 1.2em !important;">
Regular expressions provide the administrator with tools to search for any kinds of text within files. They can be added to scripts to check for patterns within user input. They are often used to identify important information from log files, email servers, and web sites. Any process that works with text can be improved by the judicious use of regular expressions.</div>
<hr />
<h2 id="powershell-examples" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
PowerShell Examples</h2>
<div style="margin: 0px 0px 1.2em !important;">
When the PowerShell <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">-match</code> operator finds the pattern in a string it returns “True”. It returns “False” if the pattern is not found.</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">PS C:\> $value = "This is a test. 1234"
PS C:\> $value -match "a.t"
True
PS C:\> $value -match "^t"
True
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Note that PowerShell is not case-sensitive.</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">PS C:\> $value -match "\st\w{3}"
True
PS C:\> $value -match "\d$"
True
PS C:\> $value -match "t[aeiou]s"
True
PS C:\> $value -match "t[^aeiou]s"
False
PS C:\> $value -match "\w+\. \d+$"
True
PS C:\> $value -match "\w+\. \d?$"
False
PS C:\> $value -match "(tisk | test)"
True
</code></pre>
<hr />
<h2 id="grep-examples" style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; font-size: 1.4em; font-weight: bold; margin: 1.3em 0px 1em; padding: 0px;">
Grep Examples</h2>
<div style="margin: 0px 0px 1.2em !important;">
The <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">grep</code> command is intended to work with files, so these examples pass a test string to the command through standard input. The command returns the string that matches the pattern, or null if there is no match.</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">$ value="This is a test. 1234"
$ echo $value | egrep a.t
This is a test. 1234
$ echo $value | egrep ^t
$ echo $value | egrep -i ^t
This is a test. 1234
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Note that grep is case-sensitive. Use the <code style="background-color: #f8f8f8; border-radius: 3px; border: 1px solid rgb(234, 234, 234); display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap;">-i</code> parameter switch to enable case-insensitive matches.</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">$ echo $value | egrep [[:space:]]t[[:alpha:]]\{3\}
This is a test. 1234
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
With grep, character classes must be quoted or contained within square brackets. The double-bracket form is the most common. Note that curly braces must be escaped.</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">$ echo $value | egrep [[:digit:]]$
This is a test. 1234
$ echo $value | egrep t[aeiou]s
This is a test. 1234
$ echo $value | egrep t[^aeiou]s
$ echo $value | egrep '[[:alpha:]]+\. [[:digit:]]+$'
This is a test. 1234
$ echo $value | egrep '[[:alpha:]]+\. [[:digit:]]?$'
$ echo $value | egrep '(tisk | test)'
This is a test. 1234
$ echo $value | egrep '\<test>'
This is a test. 1234
</test></code></pre>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PGRpdiBjbGFzcz0ibWFya2Rvd24taGVyZS13cmFwcGVyIiBkYXRhLW1kLXVybD0iaHR0cHM6Ly93
d3cuYmxvZ2dlci5jb20vYmxvZ2dlci5nP2Jsb2dJRD01MDg5MTc4NzYxOTY1MjE3NDk4I2VkaXRv
ci90YXJnZXQ9cG9zdDtwb3N0SUQ9NzIwNzEzODQzODEwNzExNTQ2NjtvblB1Ymxpc2hlZE1lbnU9
cG9zdHM7b25DbG9zZWRNZW51PXBvc3RzO3Bvc3ROdW09MTA7c3JjPWxpbmsiIHN0eWxlPSIiIG1h
cmtkb3duLWhlcmUtd3JhcHBlci1jb250ZW50LW1vZGlmaWVkPSJ0cnVlIj48cCBzdHlsZT0ibWFy
Z2luLWJvdHRvbTogMS4yZW0gIWltcG9ydGFudDsiPiMgVGhlIEJhc2ljcyBvZiBSZWd1bGFyIEV4
cHJlc3Npb25zPC9wPjxwIHN0eWxlPSJtYXJnaW4tYm90dG9tOiAxLjJ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vcmcvcGVybGludHJv
Lmh0bWwjV2hhdC1pcy1QZXJsJTNmPC9wPjxwIHN0eWxlPSJtYXJnaW4tYm90dG9tOiAxLjJlbSAh
aW1wb3J0YW50OyI+WzJdOiBodHRwOi8vd3d3LmNlbnRyaXEuY29tPC9wPjxwIHN0eWxlPSJtYXJn
aW4tYm90dG9tOiAxLjJlbSAhaW1wb3J0YW50OyI+WzNdOiBodHRwOi8vd3d3LnJlZ3VsYXItZXhw
cmVzc2lvbnMuaW5mby9wb3NpeC5odG1sPC9wPjwvZGl2Pg==">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-35459803242007279362013-03-22T07:30:00.000-05:002013-03-22T07:30:03.838-05:00for the want of a news aggregator...<p>i have to admit i have never been a google reader user. sure, i set up a profile way back when, but went off and completely forgot all about it. the recent furor over google's decision to end the project drove me back to check out my feeds—one for a service that went under 18 months ago, and the other for google. still, i like to keep up with happenings just as much as the next guy, and so i've been using a diy solution that meets my needs. i thought i'd share, because it just might meet someone else's, too.</p>
<p>my personal news reading comes from two web services. the "reader" part is handled by <a href="http://www.readability.com">readability</a>, a lovely site that takes a web page and displays it with cusomizable styles that make it easier for aging eyes to read. it has a client for ios and android, as well as doing its thing in your web browser. it also allows you to archive pages and tag them for later easy retrieval. the following image displays an article clipped from the bbc web site.</p>
<img border="0" src="http://3.bp.blogspot.com/-K1cxNWCBZlY/UUusOe8Y9UI/AAAAAAAAB-E/woz_JT9ckbI/s320/readability_test.png" />
<p>the "aggregator" part of this is a cool site called <a href="http://ifttt.com">if-this-then-that</a>. this service allows you to create recipes that perform an action based on some event: for example, if it's raining, send me an sms; if i get an email from steve, copy it to evernote; if i leave a voicemail with the words "clap on", turn on the lights in my house. this is some cool stuff. what i've done is created a few recipes that look for new items from the news feeds i'm interested in, and send those items to my reading list on readability. works for me.</p>
<p>whatever your emotional investment in google reader, don't let it get you down. there are a bevy of off-the-shelf alternatives, and even some decent homemade ones. just remember... don't worry, be happy :-) </p>Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-83003240923621989432013-03-07T09:00:00.000-06:002013-03-07T09:00:06.375-06:00make mine a double
<h3 id="using-the-copy-command">using the copy command</h3>
<p>when managing a windows server i sometimes find myself needing to copy many files. for the sake of efficiency i head for the command line. the copy command can be used to quickly make a copy of a file:</p>
<p><code>C:\>copy q1report.txt q2report.txt</code></p>
<p>this copy command takes two arguments. the first is the file to copy, the second is the name of the new file to create. when you just want to make a copy of a file in a new location, use the destination directory as the second argument:</p>
<p><code>C:\>copy q1report.txt reports</code></p>
<p>this will make a copy of q1report.txt in the c:\reports directory. you can copy multiple files at once using <em>wildcards</em>:</p>
<p><code>C:\>copy q*report.txt reports</code></p>
<h3 id="retaining-permissions-with-xcopy">retaining permissions with xcopy</h3>
<p>when you copy a file only the contents are duplicated. a file's permissions don't copy with it, but the duplicate inherits the permissions of the directory where it gets created. if you want to copy both the file and its access control list, you'll need to use xcopy:</p>
<p><code>C:\>xcopy /o q1report.txt reports</code></p>
<p>xcopy can also be used to copy whole directory trees:</p>
<p><code>C:\>xcopy /s reports d:\</code></p>
<p>this command will copy the entire directory structure under c:\reports to drive d.</p>
<h3 id="concatenating-files-with-copy">concatenating files with copy</h3>
<p>when you need to combine several files into one the copy command can be used for concatenation. just join all the old filenames together with plus symbols and specify the new filename.</p>
<p><code>C:\>copy q1report.txt+q2report.txt+q3report.txt+q4report.txt annual_report.txt</code></p>
<p>this works great for combining ascii text files together, but it's not generally very useful with binary files like those created by a word processor.</p>
<h3 id="copy-as-a-text-editor">copy as a text editor</h3>
<p>the copy command can also be used as a quick-and-dirty plain text editor. start with the command <code>copy con filename</code> and then type the lines you want in your file. when you're done, type ctrl-z.</p>
<pre><code>C:\>copy con ls.bat
@echo off
dir
^Z
</code></pre>
<p>now your batch file is saved and ready to rock 'n' roll.</p>
<p>for more advanced features, check out the command line help for copy and xcopy, and, as always, be seeing you.</p>Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-87612982217882859602013-02-25T23:20:00.000-06:002015-07-28T15:20:17.967-05:00wish (i knew when) you were here<div class="markdown-here-wrapper" data-md-url="https://www.blogger.com/blogger.g?blogID=5089178761965217498#editor/target=post;postID=8761298221788285960;onPublishedMenu=allposts;onClosedMenu=allposts;postNum=7;src=link">
<div style="margin: 0px 0px 1.2em !important;">
User accounts in Active Directory store information about the last time a user was logged in. How can we use PowerShell to get the number of days since a user last logged on to the domain? A simple way to do this is to use DateTime objects. These guys have some nifty methods that deal very effectively with operations on—well—dates and times.</div>
<div style="margin: 0px 0px 1.2em !important;">
So what we’re going to do is get a user object’s last logon as a DateTime. The property we’re looking for is<br />the <strong>LastLogonDate</strong> property. We’ll also get the current time, and use the DateTime object’s <strong>Subtract</strong> method to determine the difference between then and now.</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">$DavesLastLogon = Get-ADUser Dave -Property LastLogonDate |
Select-Object -ExpandProperty LastLogonDate
$Now = Get-Date
$DaysSinceLastLogon = $Now.Subtract($DavesLastLogon).Days
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
The resulting TimeSpan object has a <strong>Days</strong> property that we can examine and, voilà, that’s how many days have gone by since the user last logged on.</div>
<div style="margin: 0px 0px 1.2em !important;">
Use the object’s <strong>ToString</strong> method to get the days, hours, minutes and seconds in a format suitable for reports:</div>
<pre style="font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; font-size: 1em; line-height: 1.2em; margin: 1.2em 0px;"><code style="background-color: #f8f8f8; border-radius: 3px; border-radius: 3px; border: 1px solid rgb(204, 204, 204); border: 1px solid rgb(234, 234, 234); display: block !important; display: inline; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; margin: 0px 0.15em; overflow: auto; padding: 0.5em 0.7em; padding: 0px 0.3em; white-space: pre-wrap; white-space: pre;">$Now.Subtract($DavesLastLogon).ToString()
</code></pre>
<div style="margin: 0px 0px 1.2em !important;">
Be seeing you.</div>
<div style="font-size: 0em; height: 0; margin: 0; max-height: 0; max-width: 0; overflow: hidden; padding: 0; width: 0;" title="MDH:PHA+VXNlciBhY2NvdW50cyBpbiBBY3RpdmUgRGlyZWN0b3J5IHN0b3JlIGluZm9ybWF0aW9uIGFi
b3V0IHRoZSBsYXN0IHRpbWUgYSB1c2VyIHdhcyBsb2dnZWQgaW4uIEhvdyBjYW4gd2UgdXNlIFBv
d2VyU2hlbGwgdG8gZ2V0IHRoZSBudW1iZXIgb2YgZGF5cyBzaW5jZSBhIHVzZXIgbGFzdCBsb2dn
ZWQgb24gdG8gdGhlIGRvbWFpbj8gQSBzaW1wbGUgd2F5IHRvIGRvIHRoaXMgaXMgdG8gdXNlIERh
dGVUaW1lIG9iamVjdHMuIFRoZXNlIGd1eXMgaGF2ZSBzb21lIG5pZnR5IG1ldGhvZHMgdGhhdCBk
ZWFsIHZlcnkgZWZmZWN0aXZlbHkgd2l0aCBvcGVyYXRpb25zIG9uLS13ZWxsLS1kYXRlcyBhbmQg
dGltZXMuPC9wPjxwPjxicj48L3A+PHA+U28gd2hhdCB3ZSdyZSBnb2luZyB0byBkbyBpcyBnZXQg
YSB1c2VyIG9iamVjdCdzIGxhc3QgbG9nb24gYXMgYSBEYXRlVGltZS4gVGhlIHByb3BlcnR5IHdl
J3JlIGxvb2tpbmcgZm9yIGlzPC9wPjxwPnRoZSAqKkxhc3RMb2dvbkRhdGUqKiBwcm9wZXJ0eS4g
V2UnbGwgYWxz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aXRhYmxlIGZv
ciByZXBvcnRzOjwvcD48cD48YnI+PC9wPjxwPiZuYnNwOyAmbmJzcDsgJE5vdy5TdWJ0cmFjdCgk
RGF2ZXNMYXN0TG9nb24pLlRvU3RyaW5nKCk8L3A+PHA+PGJyPjwvcD48cD5CZSBzZWVpbmcgeW91
LjwvcD4=">
</div>
</div>
Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-89536387087750928392011-12-27T20:43:00.001-06:002011-12-29T15:03:21.390-06:00love my chromebook, but...it was 2002 when i installed <a href="http://www.thinkfree.com/">thinkfree office</a> as a cross-platform alternative to a popular proprietary office suite. that is when i began moving my life to the cloud. i realized that having to manage data on several computers running different operating systems was silly. i needed access to much of the same stuff on my mac, sparcstation, linux and windows pcs, and i didn't want to have to maintain multiple copies. the cloud made sense to me, though it wasn't then quite the buzzword that it has since become.<br />
<br />
back then i predicted that we would one day run most of our software over the internet on a subscription basis. while we haven't arrived there yet, we're certainly going that way. i can now edit documents, touch up photos, record music and video, take notes, send email and text messages, make phone calls, listen to music, read books, watch movies and television shows, and write code all online. since that pretty well sums up most everything i do on a computer today i decided to take the plunge and pick up a <a href="http://goo.gl/BYpdZ">chromebook</a>, the samsung series 5 with 3g (in a lovely arctic white.) i have to say, i'm loving it, and i will keep you posted here about my adventures in google's vision of the cloud.<br />
<br />
before i wrap up this post, i'll share my impressions after my first week with chromebook. i have to say, there are so many things i love about this device that i can't list them all. speed and convenience are at the top, though. but i have two needs that the chromebook doesn't address. one, i must have a local rdp client. i need to communicate with my company's terminal server from the public internet, but i also need to talk to <a href="http://goo.gl/r47Ep">virtualbox</a> machines that are running on private networks. web-based rdp-to-html5 services can't access my private ip addresses, so a local client is a must. word is, <a href="http://goo.gl/nMU8j">google is working on this</a>, so i'll wait. the second is java. now, if the chromebook had a jre then my first concern might disappear—i've found a very fine <a href="http://goo.gl/GFuEC">java rdp client</a>. but there are many web sites that use java, not the least of which are those that host games like minecraft and runescape. after all, all work and no play...Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com1tag:blogger.com,1999:blog-5089178761965217498.post-40357102372393145692011-03-30T08:19:00.003-05:002011-03-30T16:05:13.653-05:00deploying to the cloud: a white papersome folks have more experience with "cloud computing" than others. stretching back into the days of green screens and mainframes, ibm is arguably the most prolific player on the block, and they bring that 40-years of experience to you in this informative <a href="http://goo.gl/hxnJH">white paper</a>. the link requires free registration—a small price to pay for some valuable information.<div><br /></div><div>until next time.</div>Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-52955345653232432402010-12-25T10:00:00.004-06:002010-12-28T09:49:04.047-06:00"ruby, any messages for me?"i have successfully consolidated all of my email accounts to gmail. this makes it easy for me to read all my messages from my android phone or other portable internet devices. during the work week i'm rather tied to my email, but it does no good to leave a web browser tab open on the gmail site while i'm teaching class, and it eats up resources unnecessarily. so, i knocked off this little ruby script to check the google xml feed and determine if i have any new mail messages. this simply displays in my <a href="http://goo.gl/Mtcv9">conky</a> resource monitor on my desktop, but you can do something fancier, even use this in a more elaborate mail fetching script, if you wish.<br /><pre style="color: white; background-color: #000033; width: 93ex; padding: 1ex;"><br />01 <span style="color: #0066ff; font-style: italic;">#!/usr/bin/ruby</span><br />02 <span style="color: #0066ff; font-style: italic;"># gmail.rb</span><br />03 <span style="color: #0066ff; font-style: italic;"># Checks a gmail account and displays the number of unread (new) messages</span><br />04 <span style="color: #0066ff; font-style: italic;"># waiting on the server.</span><br />05 <span style="color: #0066ff; font-style: italic;"># Robert Ritter <rritter@centriq.com></span><br />06 <span style="color: #0066ff; font-style: italic;"># December 20, 2010</span><br />07<br />08 <span style="color: #0066ff; font-style: italic;"># Use 'nokogiri' to parse XML.</span><br />09 <span style="color: cyan;">require</span> <span style="color: #00ff00;">'nokogiri'</span><br />10 <span style="color: cyan;">require</span> <span style="color: #00ff00;">'open-uri'</span><br />11<br />12 username = <span style="color: #00ff00;">'not_a_real_user@gmail.com'</span><br />13 password = <span style="color: #00ff00;">'not_a_real_password_either'</span><br />13<br />14 tree = Nokogiri.XML(open(<span style="color: #00ff00;">'https://mail.google.com/mail/feed/atom'</span>,<br />15 <span style="color: magenta;">:http_basic_authentication</span>=>[username, password]))<br />16 <br />17 puts tree.xpath(<span style="color: #00ff00;">'//xmlns:fullcount'</span>).first.content<br />18<br /></rritter@centriq.com></pre><br />until next time!Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-68296996506643258642010-12-20T11:10:00.004-06:002010-12-20T11:27:36.126-06:00three wee scripts in powershell 2...'tis the season of giving. several of my students have been asking for advanced user interface examples in powershell, so here are <a href="http://ritterhaus.public.s3.amazonaws.com/UIScripts.zip">three scripts</a> (and a module) for them, you, and anyone else who cares to look. they are heavily commented so i'll not go into details, but this is what i got you for christmas...<br /><br /><b>screenctl.psm1</b> is a module that contains three useful functions used by the scripts in this set. <i>set-cursor</i> places the cursor exactly where you want it on the screen, so that whatever you print starts displaying there. <i>clear-lines</i> clears a specific number of lines from the screen, rather than the whole thing. combined with set-cursor you can clear just a small section of the screen if you wish. <i>out-wrappedstring</i> is a variation of the text-wrapping function i talked about <a href="http://mechatechzilla.blogspot.com/2010/07/powershell-my-3-favorite-functions-2-of.html">here</a>.<br /><br /><b>addusers.ps1</b> walks you through adding a user account to active directory. it uses the screenctl module to customize the output and the activedirectory module to read and write the database.<br /><br /><b>get-weather.ps1</b> provides current conditions and forecast from an internet xml stream. it uses the screenctl module to wrap long forecast strings.<br /><br /><b>netcfg.ps1</b> provides a graphical interface to the network information for machines listed in active directory. it uses the active directory module to locate computers.<br /><br />read the example scripts, improve them, have fun with them this holiday season. it's better than listening to uncle lloyd snore in front of the television, right?Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-22054039365217363392010-08-26T08:43:00.007-05:002010-08-26T11:28:51.369-05:00random passwords in powershell<style>#pscode{ font-weight: bold; background-color: palegoldenrod; color: black; padding: 1em; width: 51em; } #command{ font-weight: bold; background-color: navy; color: silver; padding: 1em; width: 51em;} .comment{ color: darkgreen;} .keyword{ color: navy; } .function{ color: teal; } .var { color: magenta; } .string{ color: maroon; } .op{ color: red; } .option{ color: darkcyan; font-style: oblique; } .optname{ color: purple; font-style: oblique; } .num {color: purple}</style><br />recently i was teaching my students how to read hundreds of user accounts from a text file and create them in active directory in seconds with a powershell script. to the script we added a nifty function to generate random initial passwords that meet the complexity requirements of windows. here's our function:<br /><pre id="pscode"><br />9 <span class="comment"># new_password</span><br />10 <span class="comment"># Returns a string.</span><br />11 <span class="comment"># Generates a random password for the user that meets Windows' complexity</span><br />12 <span class="comment"># requirements.</span><br />13 <span class="keyword">function</span> <span class="function">new_password</span> {<br />14 <span class="var">$randomizer</span> <span class="op">=</span> <span class="function">New-Object</span> <span class="function">System.Random</span><br />15 <span class="var">$password</span> <span class="op">=</span> [<span class="function">char</span>] <span class="var">$randomizer</span>.next(<span class="num">65</span>,<span class="num">91</span>) <span class="comment"># Uppercase letters</span><br />16 <span class="var">$password</span> <span class="op">+=</span> [<span class="function">char</span>] <span class="var">$randomizer</span>.next(<span class="num">48</span>,<span class="num">58</span>) <span class="comment"># Numbers</span><br />17 <span class="var">$password</span> <span class="op">+=</span> [<span class="function">char</span>] <span class="var">$randomizer</span>.next(<span class="num">91</span>,<span class="num">127</span>) <span class="comment"># Lowercase letters</span><br />18 <span class="comment"># and punctuation</span><br />19 <span class="keyword">foreach</span> (<span class="var">$time</span> <span class="keyword">in</span> <span class="num">1</span>..<span class="num">7</span>) {<br />20 <span class="var">$password</span> <span class="op">+=</span> [<span class="function">char</span>] <span class="var">$randomizer</span>.next(<span class="num">32</span>,<span class="num">127</span>)<br />21 }<br />22 <span class="keyword">return</span> <span class="var">$password</span><br />23 } <span class="comment"># end function new_password</span><br />24<br /></pre><br />don't forget to write the passwords out to a file when you're done so that you can tell users what they are:<br /><pre id="pscode"><br />.<br />.<br />.<br />62 <span class="comment"># Write the username and password to a file.</span><br />63 <span class="string">"{0,-19} {1}"</span> <span class="op">-f</span> <span class="var">$samAccountName</span>, <span class="var">$password</span> <span class="op">>></span> userspass.txt<br />64 <span class="string">"-"</span> <span class="op">*</span> <span class="num">30</span> <span class="op">>></span> userspass.txt<br />65<br /></pre><br />until next time.Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-44018306272084692042010-07-29T20:59:00.026-05:002010-08-03T19:35:11.973-05:00xml 2: and now, a word from our compilers...<style>#cscode{ font-weight: bold; background-color: #303030; color: #aaaaaa; padding: 1em; width: 53em; } #command{ font-weight: bold; background-color: navy; color: silver; padding: 1em; width: 51em;} .dcomment{ color: #666666;} .dkeyword{ color: mediumorchid; } .function{ color: teal; } .var { color: magenta; } .dstring{ color: gold; } .op{ color: red; } .option{ color: darkcyan; font-style: oblique; } .optname{ color: purple; font-style: oblique; } .dnum { color: gold} .type { color: lime; } .null { color: chocolate; } .if { color: white; } .include { font-style: oblique; color: cornflowerblue; }</style><br />last time i demonstrated how to read xml data from a file, looking at the xml support in a few scripting languages. so that we might round out this discussion i will now show how to do the exact same thing with the exact same data using a handful of compiled languages. refer to my <a href="http://goo.gl/opbp">previous post</a> to get the xml file and view what the program output should be.<br /><br />the first language we'll look at is the one of the three that i am least familiar with: c#. despite the fact that i've never used the language outside the classroom and never written a line of “real” production code with it, this was the easiest to use. c# reads and writes much like the scripting languages we looked at last time.<br /><br /><pre id="cscode"><br />1 <span class="dcomment">// xmlsearch.cs</span><br />2<br />3 <span class="dcomment">// Demonstrates how to parse data in an XML file using C-sharp's XPath</span><br />4 <span class="dcomment">// implementation. The file is a collection of books, tech_books.xml.</span><br />5<br />6 <span class="dkeyword">using</span> System;<br />7 <span class="dkeyword">using</span> System.Xml;<br />8<br />9<br />10 <span class="dkeyword">class</span> XmlSearch {<br />11 <br />12 <span class="dkeyword">static</span> void Main(<span class="type">string</span>[] args) {<br />13 String separator = <span class="dstring">"- - - - - - - - - - - - - - - - - - - - - - - - -"</span>;<br />14 XmlDocument tree = new XmlDocument();<br />15 tree.Load(<span class="dstring">"tech_books.xml"</span>);<br />16 <br />17 <span class="dcomment">// List all the books by title and author from the XML data.</span><br />18 XmlNodeList books = tree.SelectNodes(<span class="dstring">"//publisher//book"</span>);<br />19 <span class="dkeyword">foreach</span>(XmlNode book <span class="dkeyword">in</span> books) {<br />20 Console.WriteLine(<span class="dstring">"Title: {0}"</span>, <br />21 book.SelectSingleNode(<span class="dstring">"title"</span>).InnerText);<br />22 <span class="if">if</span>(book.SelectSingleNode(<span class="dstring">"subtitle"</span>) != <span class="null">null</span>) {<br />23 Console.WriteLine(<span class="dstring">"Subtitle: {0}"</span>,<br />24 book.SelectSingleNode(<span class="dstring">"subtitle"</span>).InnerText);<br />25 }<br />26 <span class="dkeyword">foreach</span>(XmlNode author <span class="dkeyword">in</span> book.SelectNodes(<span class="dstring">"author"</span>)){<br />27 Console.WriteLine(<span class="dstring">"Author: {0}"</span>, author.InnerText);<br />28 }<br />29 Console.WriteLine(separator);<br />30 }<br />31 <br />32 <span class="dcomment">// Get the ISBN and publisher for a book called "Writing Solid Code."</span><br />33 Console.WriteLine(separator);<br />34 String search = <span class="dstring">"Writing Solid Code"</span>;<br />35 <span class="dkeyword">foreach</span>(XmlNode book <span class="dkeyword">in</span> books) {<br />36 <span class="if">if</span>(book.SelectSingleNode(<span class="dstring">"title"</span>).InnerText == search) {<br />37 Console.WriteLine(<span class="dstring">"{0} [{1}] published by {2}"</span>, search,<br />38 book.SelectSingleNode(<span class="dstring">"isbn"</span>).InnerText,<br />39 book.ParentNode.Attributes[<span class="dstring">"name"</span>].Value);<br />40 }<br />41 }<br />42 Console.WriteLine(separator);<br />43 } <span class="dcomment">// end method Main</span><br />44 <br />45 } <span class="dcomment">// end class XmlSearch</span><br />46<br /></pre><br />the next example is in java. while i have worked with java, i've never had to make it read xml before. i was a little disappointed. with factory classes and old-fashioned for loops it's more like c than c#.<br /><br /><pre id="cscode"><br />1 <span class="dcomment">/* XmlSearch.java</span><br />2 <span class="dcomment">**</span><br />3 <span class="dcomment">** Demonstrates how to parse data in an XML file using Java's XPath API.</span><br />4 <span class="dcomment">** The file is a collection of books, tech_books.xml.</span><br />5 <span class="dcomment">*/</span><br />6<br />7 <span class="dkeyword">import</span> javax.xml.parsers.*;<br />8 <span class="dkeyword">import</span> javax.xml.xpath.*;<br />9 <span class="dkeyword">import</span> org.w3c.dom.*;<br />10<br />11<br />12 <span class="dkeyword">public class</span> XmlSearch {<br />13 <br />14 <span class="dkeyword">public static</span> void main(String[] args) <br />15 <span class="dkeyword">throws</span> ParserConfigurationException, XPathExpressionException,<br />16 org.xml.sax.SAXException, java.io.IOException {<br />17 <br />18 String separator = <span class="dstring">"- - - - - - - - - - - - - - - - - - - - - - - - -"</span>;<br />19 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();<br />20 Document tree = factory.newDocumentBuilder().parse(<span class="dstring">"tech_books.xml"</span>);<br />21 XPath xp = XPathFactory.newInstance().newXPath();<br />22 <br />23 <span class="dcomment">// List all the books by title and author from the XML data.</span><br />24 NodeList books = (NodeList)xp.evaluate(<span class="dstring">"//publisher//book"</span>, tree, <br />25 XPathConstants.NODESET);<br />26 <span class="dkeyword">for</span>(int i = <span class="dnum">0</span>; i < books.getLength(); i++) {<br />27 Node book = books.item(i);<br />28 System.out.printf(<span class="dstring">"Title: %s\n"</span>,<br />29 xp.evaluate("title", book, XPathConstants.STRING));<br />30 <span class="if">if</span>((xp.evaluate(<span class="dstring">"subtitle"</span>, book, XPathConstants.NODE)) != <span class="null">null</span>) {<br />31 System.out.printf(<span class="dstring">"Subtitle: %s\n"</span>,<br />32 xp.evaluate(<span class="dstring">"subtitle"</span>, book, XPathConstants.STRING));<br />33 }<br />34 NodeList authors = (NodeList)xp.evaluate(<span class="dstring">"author"</span>, book,<br />35 XPathConstants.NODESET);<br />36 <span class="dkeyword">for</span>(<span class="type">int</span> j = <span class="dnum">0</span>; j < authors.getLength(); j++) {<br />37 System.out.printf(<span class="dstring">"Author: %s\n"</span>, <br />38 authors.item(j).getTextContent());<br />39 }<br />40 System.out.println(separator);<br />41 }<br />42 <br />43 <span class="dcomment">// Get the ISBN and publisher for a book called "Writing Solid Code."</span><br />44 System.out.println(separator);<br />45 String search = <span class="dstring">"Writing Solid Code"</span>;<br />46 <span class="dkeyword">for</span>(<span class="type">int</span> i = <span class="dnum">0</span>; i < books.getLength(); i++) {<br />47 Node book = books.item(i);<br />48 <span class="if">if</span>(search.equals(<br />49 xp.evaluate(<span class="dstring">"title"</span>, book, XPathConstants.STRING))) {<br />50 System.out.printf(<span class="dstring">"%s [%s] published by %s\n"</span>, search,<br />51 xp.evaluate(<span class="dstring">"isbn"</span>, book, XPathConstants.STRING),<br />52 ((Element)book.getParentNode()).getAttribute(<span class="dstring">"name"</span>));<br />53 }<br />54 }<br />55 System.out.println(separator);<br />56 } <span class="dcomment">// end method main</span><br />57 <br />58 } <span class="dcomment">// end class XmlSearch</span><br />59<br /></pre><br />for the sake of completeness, here is the code to do the same thing in c. i'm using libxml2 for its xdom and xpath capabilities. since this is a short example, i have simplified it by excluding all pointer and memory management. <em>don't ever do that in real life.</em> be sure to clean up after yourself: your parent object doesn't work here.<br /><!-- <br />-------------------------------------- c example --------------------------------------------------><br /><pre id="cscode"><br />1 <span class="dcomment">/* xmlsearch.c</span><br />2 <span class="dcomment">*</span> <br />3 <span class="dcomment">* Demonstrates how to parse data in an XML file using LIBXML2 and XPath in C.</span><br />4 <span class="dcomment">* The file is a collection of books, tech_books.xml.</span><br />5 <span class="dcomment">*/</span><br />6<br />7 <span class="include">#include <stdio.h></span><br />8 <span class="include">#include <stdlib.h></span><br />9 <span class="include">#include <libxml/parser.h></span><br />10 <span class="include">#include <libxml/xpath.h></span><br />11<br />12<br />13 <span class="type">int</span> main(<span class="type">int</span> argc, <span class="type">char</span> **argv) {<br />14 xmlDocPtr doc;<br />15 xmlXPathContextPtr tree;<br />16 xmlXPathObjectPtr result;<br />17 xmlNodeSetPtr nodeList;<br />18 xmlNodePtr book, cursor;<br />19 xmlChar *title, *subtitle, *author, *search, *isbn, *publisher;<br />20 <span class="type">char</span> *separator = <span class="dstring">"- - - - - - - - - - - - - - - - - - - - - - - - -";</span><br />21 <span class="type">int</span> found = <span class="dnum">0</span>;<br />22 <br />23 doc = xmlParseFile(<span class="dstring">"tech_books.xml"</span>);<br />24 tree = xmlXPathNewContext(doc);<br />25 result = xmlXPathEvalExpression((xmlChar *)<span class="dstring">"//publisher//book"</span>, tree);<br />26 nodeList = result->nodesetval;<br />27 <br />28 <span class="dcomment">// List all the books by title and author from the XML data.</span><br />29 <span class="dkeyword">for</span>(<span class="type">int</span> i = <span class="dnum">0</span>; i < nodeList->nodeNr; i++) {<br />30 book = nodeList->nodeTab[i];<br />31 cursor = book->xmlChildrenNode;<br />32 <span class="dkeyword">while</span>(cursor != <span class="null">NULL</span>) {<br />33 <span class="if">if</span>((!xmlStrcmp(cursor->name, (xmlChar *)<span class="dstring">"title"</span>))) {<br />34 title = xmlNodeListGetString(doc, cursor->xmlChildrenNode, <span class="dnum">1</span>);<br />35 printf(<span class="dstring">"Title: %s\n"</span>, title);<br />36 }<br />37 <span class="if">if</span>((!xmlStrcmp(cursor->name, (xmlChar *)<span class="dstring">"subtitle"</span>))) {<br />38 subtitle = xmlNodeListGetString(doc,<br />39 cursor->xmlChildrenNode, <span class="dnum">1</span>);<br />40 printf(<span class="dstring">"Subtitle: %s\n"</span>, subtitle);<br />41 }<br />42 <span class="if">if</span>((!xmlStrcmp(cursor->name, (xmlChar *)<span class="dstring">"author"</span>))) {<br />43 author = xmlNodeListGetString(doc, cursor->xmlChildrenNode, <span class="dnum">1</span>);<br />44 printf(<span class="dstring">"Author: %s\n"</span>, author);<br />45 }<br />46 cursor = cursor->next;<br />47 }<br />48 puts(separator);<br />49 }<br />50 <br />51 <span class="dcomment">// Get the ISBN and publisher for a book called "Writing Solid Code."</span><br />52 puts(separator);<br />53 search = (xmlChar *)<span class="dstring">"Writing Solid Code"</span>;<br />54 result = xmlXPathEvalExpression((xmlChar *)<span class="dstring">"//publisher"</span>, tree);<br />55 nodeList = result->nodesetval;<br />56 <br />57 <span class="dkeyword">for</span>(<span class="type">int</span> i = <span class="dnum">0</span>; i < nodeList->nodeNr; i++) {<br />58 cursor = nodeList->nodeTab[i];<br />59 publisher = xmlGetProp(cursor, (xmlChar *)<span class="dstring">"name"</span>);<br />60 book = cursor->xmlChildrenNode;<br />61 book = book->next;<br />62 <span class="dkeyword">while</span>(book != <span class="null">NULL</span>) {<br />63 cursor = book->xmlChildrenNode;<br />64<br />65 <span class="dkeyword">while</span>(cursor != <span class="null">NULL</span>) {<br />66 <span class="if">if</span>((!xmlStrcmp(cursor->name, (xmlChar *)<span class="dstring">"title"</span>))) {<br />67 title = xmlNodeListGetString(doc, <br />68 cursor->xmlChildrenNode, <span class="dnum">1</span>);<br />69 }<br />70 <span class="if">if</span>((!xmlStrcmp(cursor->name, (xmlChar *)<span class="dstring">"isbn"</span>))) {<br />71 isbn = xmlNodeListGetString(doc, <br />72 cursor->xmlChildrenNode, <span class="dnum">1</span>);<br />73 }<br />74 cursor = cursor->next;<br />75 }<br />76 <span class="if">if</span>((!xmlStrcmp(title, search))) {<br />77 found = <span class="dnum">1</span>;<br />78 <span class="dkeyword">break</span>;<br />79 }<br />80 book = book->next;<br />81 }<br />82 <span class="if">if</span>(found) {<br />83 printf(<span class="dstring">"%s [%s] published by %s\n"</span>, title, isbn, publisher);<br />84 <span class="dkeyword">break</span>;<br />85 }<br />86 }<br />87 puts(separator);<br />88 <br />89 return <span class="dnum">0</span>;<br />90 } <span class="dcomment">// end method main</span><br />91<br /></pre>Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0tag:blogger.com,1999:blog-5089178761965217498.post-43375309839262499642010-07-25T23:48:00.011-05:002010-07-25T23:48:00.598-05:00reading xml 1: powershell, python and ruby, oh my!<style>#pscode{ font-weight: bold; background-color: palegoldenrod; color: black; padding: 1em; width: 51em; } #command{ font-weight: bold; background-color: navy; color: silver; padding: 1em; width: 51em;} .comment{ color: darkgreen;} .keyword{ color: navy; } .function{ color: teal; } .var { color: magenta; } .string{ color: maroon; } .op{ color: red; } .option{ color: darkcyan; font-style: oblique; } .optname{ color: purple; font-style: oblique; } .num {color: purple}</style><br />i was working on a little project that required me to read an xml file from the internet. since i like to have some useful examples to refer to when i'm doing something that i don't often do (and so don't remember how to) i decided to dig into the three scripting languages that i'm most likely to use and learn how to work with xml data.<br/><br />you can grab the sample xml file here: <a href="http://ritterhaus.public.s3.amazonaws.com/tech_books.xml">tech_books.xml</a>. i recommend that you look it over so you can see what the scripts are doing. we'll be writing scripts to list all the book titles and authors, then search for a specific title and fetch its isbn and its parent publisher's <i>name</i> attribute. all three should provide the same output, which you can see below:<br /><pre style="font-size: smaller;"><br />Title: The Revolutionary Guide to Assembly Language<br />Author: Vitaly Maljugin<br />Author: Jacov Izrailevich<br />Author: A. Sopin<br />Author: S. Lavin<br />- - - - - - - - - - - - - - - - - - - - - - - - - <br />Title: Writing Solid Code<br />Subtitle: Microsoft's Techniques for Developing Bug-Free C Programs<br />Author: Steve Maguire<br />- - - - - - - - - - - - - - - - - - - - - - - - - <br />Title: Windows PowerShell Scripting Guide<br />Subtitle: Automating Administration of Windows Vista and Windows Server 2008<br />Author: Ed Wilson<br />- - - - - - - - - - - - - - - - - - - - - - - - - <br />Title: Practical C Programming<br />Author: Steve Oualline<br />- - - - - - - - - - - - - - - - - - - - - - - - - <br />Title: Programming Python<br />Author: Mark Lutz<br />- - - - - - - - - - - - - - - - - - - - - - - - - <br />Title: The Ruby Way, Second Edition<br />Author: Hal Fulton<br />- - - - - - - - - - - - - - - - - - - - - - - - - <br />Title: LaTeX: A Document Preparation System<br />Author: Leslie Lamport<br />- - - - - - - - - - - - - - - - - - - - - - - - - <br />- - - - - - - - - - - - - - - - - - - - - - - - - <br />Writing Solid Code [ISBN 1-556-15551-4] published by Microsoft Press<br />- - - - - - - - - - - - - - - - - - - - - - - - - <br /></pre><br />the first language i turned to is python, an old friend of mine. reading through the xml document object model api made my head swim, but with a little research i came across what used to be a third-party module, elementtree, that has now been incorporated into the core python installation. (this is one of the reasons that i love open source software.)<br/><br />elementtree uses <i>parent</i>.findall(<i>child</i>) to fetch an array of all nodes of type <i>child</i> under <i>parent</i>. the <i>parent</i>.find(<i>child</i>) method returns only a single element object. <i>parent</i>.findtext(<i>child</i>) returns the child node data. it is similar to <i>parent</i>.find(<i>child</i>).text: the former returns an empty string if the element is not found, the latter raises an exception. <i>element</i>.get(<i>attribute</i>) returns a node's attribute value.<br /><br /><pre id="pscode"><br />1 <span class="comment"># xmlsearch.py</span><br />2<br />3 <span class="keyword">import</span> <span class="function">xml.etree.ElementTree</span><br />4<br />5<br />6 tree <span class="op">=</span> xml.etree.ElementTree.ElementTree()<br />7 tree.parse(<span class="string">'tech_books.xml'</span>)<br />8<br />9 <span class="comment"># List all the books by title and author from the XML data.</span><br />10 books <span class="op">=</span> tree.findall(<span class="string">'publisher/book'</span>)<br />11 <span class="keyword">for</span> book <span class="keyword">in</span> books:<br />12 <span class="keyword">print</span> <span class="string">"Title: %s"</span> <span class="op">%</span> book.findtext(<span class="string">'title'</span>)<br />13 <span class="keyword">if</span> book.findtext(<span class="string">'subtitle'</span>):<br />14 <span class="keyword">print</span> <span class="string">"Subtitle: %s"</span> <span class="op">%</span> book.findtext(<span class="string">'subtitle'</span>)<br />15 authors <span class="op">=</span> book.findall(<span class="string">'author'</span>)<br />16 <span class="keyword">for</span> author <span class="keyword">in</span> authors:<br />17 <span class="keyword">print</span> <span class="string">"Author: %s"</span> <span class="op">%</span> author.text<br />18 <span class="keyword">print</span> <span class="string">'- '</span> <span class="op">*</span> <span class="num">25</span><br />19 <br />20 <span class="comment"># Get the ISBN and publisher for a book called "Writing Solid Code."</span><br />21 <span class="keyword">print</span> <span class="string">'- '</span> <span class="op">*</span> <span class="num">25</span><br />22 search <span class="op">=</span> <span class="string">'Writing Solid Code'</span><br />23 publishers <span class="op">=</span> tree.findall(<span class="string">'publisher'</span>)<br />24 <span class="keyword">for</span> publisher <span class="keyword">in</span> publishers:<br />25 books <span class="keyword">=</span> publisher.findall(<span class="string">'book'</span>)<br />26 <span class="keyword">for</span> book <span class="keyword">in</span> books:<br />27 <span class="keyword">if</span> book.findtext(<span class="string">'title'</span>) <span class="op">==</span> search:<br />28 <span class="keyword">print</span> <span class="string">"%s [ISBN %s] published by %s"</span> <span class="op">%</span> (search, <br />29 book.findtext(<span class="string">'isbn'</span>), publisher.get(<span class="string">'name'</span>))<br />30 <span class="keyword">print</span> <span class="string">'- '</span> <span class="op">*</span> <span class="num">25</span><br />31<br /></pre><br />next i investigated xml under powershell. i was certain that it would be no more difficult than python, and what i found was that basic xml searches worked in a very similar way.<br/><br />powershell has xml processing built-in, so no modules have to be included in the source file to make it work. it uses <i>parent</i>.SelectNodes(<i>child</i>) to get an array of all nodes called <i>child</i> under the node <i>parent</i>. the <i>parent</i>.SelectNode(<i>child</i>) method returns only the first node <i>child</i> that is found under <i>parent</i>. note the plural <i>SelectNodes</i> and singular <i>SelectNode</i>. <i>element</i>.GetAttribute(<i>attribute</i>) returns a node's attribute value.<br /><br /><pre id="pscode"><br />1 <span class="comment"># xmlsearch.ps1</span><br />2<br />3 [<span class="function">xml</span>] <span class="var">$tree</span> <span class="op">=</span> <span class="function">Get-Content</span> tech_books.xml<br />4<br />5 <span class="comment"># List all the books by title and author from the XML data.</span><br />6 <span class="var">$books</span> = <span class="var">$tree</span>.SelectNodes(<span class="string">'//publisher//book'</span>)<br />7 <span class="keyword">foreach</span> (<span class="var">$book</span> <span class="keyword">in</span> <span class="var">$books</span>) {<br />8 <span class="string">"Title: {0}"</span> <span class="op">-f</span> <span class="var">$book</span>.title<br />9 <span class="keyword">if</span> (<span class="var">$book</span>.subtitle) {<br />10 <span class="string">"Subtitle: {0}"</span> <span class="op">-f</span> <span class="var">$book</span>.subtitle<br />11 }<br />12 <span class="var">$authors</span> = <span class="var">$book</span>.SelectNodes(<span class="string">'author'</span>)<br />13 <span class="keyword">foreach</span> (<span class="var">$author</span> <span class="keyword">in</span> <span class="var">$authors</span>) {<br />14 <span class="string">"Author: {0}"</span> <span class="op">-f</span> <span class="var">$author</span>.<span class="string">'#text'</span><br />15 }<br />16 <span class="string">'- '</span> <span class="op">*</span> <span class="num">25</span><br />17 }<br />18<br />19 <span class="comment"># Get the ISBN and publisher for a book called "Writing Solid Code."</span><br />20 <span class="string">'- '</span> <span class="op">*</span> <span class="num">25</span><br />21 <span class="var">$search</span> = <span class="string">'Writing Solid Code'</span><br />22 <span class="var">$publishers</span> <span class="op">=</span> <span class="var">$tree</span>.SelectNodes(<span class="string">'//publisher'</span>)<br />23 <span class="keyword">foreach</span> (<span class="var">$publisher</span> <span class="keyword">in</span> <span class="var">$publishers</span>) {<br />24 <span class="var">$books</span> <span class="op">=</span> <span class="var">$publisher</span>.SelectNodes(<span class="string">'book'</span>)<br />22 <span class="keyword">foreach</span> (<span class="var">$book</span> <span class="keyword">in</span> <span class="var">$books</span>) {<br />23 <span class="keyword">if</span> (<span class="var">$book</span>.title <span class="op">-eq</span> <span class="var">$search</span>) {<br />24 <span class="string">"{0} [ISBN {1}] published by {2}"</span> <span class="op">-f</span> <span class="var">$search</span>, <span class="var">$book</span>.isbn,<br />25 <span class="var">$publisher</span>.GetAttribute(<span class="string">'name'</span>)<br />26 }<br />25 }<br />26 }<br />27 <span class="string">'- '</span> <span class="op">*</span> <span class="num">25</span><br />28<br /></pre><br />finally i dusted off ruby, a language that i haven't really touched in more than a year, to see what it would do. again, i wasn't impressed with the general xml documentation, but google searches led me to a ruby gem called nokogiri. i installed it and was very pleased with the result.<br/><br />nokogiri uses <i>parent</i>.xpath(<i>child</i>) to get an array of <i>child</i> elements, <i>parent</i>.at_xpath(<i>child</i>) to get a single element, and <i>element</i>.attr(<i>attribute</i>) to get a node's attribute value. one nifty property lacking in the other two languages is <i>element</i>.parent, which returns the parent node of the current element. it saves us from having to define multiple “books” arrays in this example.<br /><br /><pre id="pscode"><br />1 <span class="comment"># xmlsearch.rb</span><br />2<br />3 <span class="keyword">require</span> <span class="string">'rubygems'</span><br />4 <span class="keyword">require</span> <span class="string">'nokogiri'</span><br />5<br />6<br />7 tree <span class="op">=</span> Nokogiri.XML(open(<span class="string">'tech_books.xml'</span>))<br />8<br />9 <span class="comment"># List all the books by title and author from the XML data.</span><br />10 books <span class="op">=</span> tree.xpath(<span class="string">'//publisher//book'</span>)<br />11 books.each <span class="keyword">do</span> |book|<br />12 <span class="keyword">puts</span> <span class="string">"Title: %s"</span> <span class="op">%</span> book.at_xpath(<span class="string">'title'</span>).content<br />13 <span class="keyword">if</span> book.at_xpath(<span class="string">'subtitle'</span>)<br />14 <span class="keyword">puts</span> <span class="string">"Subtitle: %s"</span> <span class="op">%</span> book.at_xpath(<span class="string">'subtitle'</span>).content<br />15 <span class="keyword">end</span><br />16 authors <span class="op">=</span> book.xpath(<span class="string">'author'</span>)<br />17 authors.each <span class="keyword">do</span> |author|<br />18 <span class="keyword">puts</span> <span class="string">"Author: %s"</span> <span class="op">%</span> author.content<br />19 <span class="keyword">end</span><br />20 <span class="keyword">puts</span> <span class="string">'- '</span> <span class="op">*</span> <span class="num">25</span><br />21 <span class="keyword">end</span><br />22<br />23 <span class="comment"># Get the ISBN and publisher for a book called "Writing Solid Code."</span><br />24 <span class="keyword">puts</span> <span class="string">'- '</span> <span class="op">*</span> <span class="num">25</span><br />25 search <span class="op">=</span> <span class="string">'Writing Solid Code'</span><br />26 books.each <span class="keyword">do</span> |book|<br />27 <span class="keyword">if</span> book.at_xpath(<span class="string">'title'</span>).content <span class="op">==</span> search<br />28 <span class="keyword">puts</span> <span class="string">"%s [ISBN %s] published by %s"</span> <span class="op">%</span> [search, <br />29 book.at_xpath(<span class="string">'isbn'</span>).content, book.parent.attr(<span class="string">'name'</span>)]<br />29 <span class="keyword">end</span><br />30 <span class="keyword">end</span><br />31 <span class="keyword">puts</span> <span class="string">'- '</span> <span class="op">*</span> <span class="num">25</span><br />32<br /></pre><br />so after doing a little research i find that it's not really too difficult to read xml in my favorite scripting languages, and now i have some nice little examples to look at the next time i need a refresher. until next time.Robhttp://www.blogger.com/profile/17585447008783853422noreply@blogger.com0