Home

Advertisement

Previous 20

Jun. 7th, 2009

Seashore

Fun with Pipes...

For those who haven't heard of Pipes, it allows you to manipulate RSS data feeds into something that is more useful to you. I have know about Pipes for a while but hadn't come up with a good use for it. That changed last night when I decided to cut down some of the feeds that I read to a reasonable size.

I subscribe to the "Recent Posts" feed from RPG.net to keep up with some of the interesting things that are going on there. Unfortunately, the signal to noise ratio for those fora is significant and makes seeing anything useful nearly impossible. This is where Pipes comes in, I can set it up to filter the RSS feed from RPG.net and thus eliminate much of the noise and get the parts that I'm interested in reading.

I've also augmented it a forum feed from the new White Wolf fora that looks for Anathema and sends the results to me. This addition is particularly useful because I don't tend to frequent the WW fora and this will bring the results directly to my attention.


Jan. 11th, 2009

Seashore

More fun with CMD scripts: Download new screensavers...

This code does two major things. 1). Delete any "stale" videos. 2). Download/update new videos.


@echo off
setLocal

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::
:: Daytime.cmd
:: v1 - And so it begins...
:: v2 - Added more logging, text redirection, and correctly escaped the % sign in the password.
:: v3 - Combined this with the daytime script.
:: v4 - Complete overhaul of script: Intelligent deletion of stale files and intelligent updating.
:: v5 - Updated login segment to deal with login failure.
:: v6 - Fixed error with delimiters.


:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:: Various environmental variables.

set COPYCMD="/y"
set PATH="%WINDIR:"=%\System32"

set SHARE_PATH="%SERVER1:"=%\sales_videos\current"
set DEST_PATH="%USERPROFILE:"=%\My Documents\My Videos"

set LOG="%TMP:"=%/log-daytime.txt"

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

date /t > "%LOG:"=%" 2>&1
time /t >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

echo "Setting power profile to 'Always on'." >> "%LOG:"=%" 2>&1
powercfg /setactive "Always on" >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:SME_Login
echo "Disable connection logging." >> "%LOG:"=%" 2>&1
net use /persistent:"no" >> "%LOG:"=%" 2>&1

:Login_Counter
set /a LOGIN_COUNTER+=1 >> "%LOG:"=%" 2>&1
if %LOGIN_COUNTER:"=% equ 11 (goto end) >> "%LOG:"=%" 2>&1
echo "Login attempt %LOGIN_COUNTER:"=% with SME workgroup server." >> "%LOG:"=%" 2>&1
net use "%SERVER1:"=%" /user:"%SERVER1_USER:"=%" "%SERVER1_PASS:"=%" >> "%LOG:"=%" 2>&1
if %ERRORLEVEL% neq 0 (goto Login_Counter) >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:Stale_Video
echo "Deleting stale/old video's from host machine." >> "%LOG:"=%" 2>&1
for /f "tokens=1* delims=:" %%a in ('dir /b %DEST_PATH%\*.wmv') do (if not exist "%SHARE_PATH:"=%\%%a" (del /f /q "%DEST_PATH:"=%\%%a")) >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:Update_Video
echo "Downloading updated/new video's from network." >> "%LOG:"=%" 2>&1
xcopy /c /d /v /z "%SHARE_PATH:"=%\*.wmv" "%DEST_PATH:"=%" >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:SME_Logoff
echo "Logging off of SME workgroup server." >> "%LOG:"=%" 2>&1
net use /delete "%SERVER1:"=%\IPC$" >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:end
endLocal
@echo on
exit


PS. In the case that anyone is interested, I have the Windows 7 beta!

Oct. 7th, 2008

Seashore

Fun with TextMate...

There is a new download on the Yushan site. It is an enhancement to TextMate that makes it work better for creating charm XML for Anathema. It is a work in progress, so if you have any suggestions, let me know.

Yushan on Google Code

A somewhat better looking copy.

Sep. 22nd, 2008

Seashore

New Music...

I'm in the mood to get some new music. At the moment, I'm interested in music that is roughly related to my lineage. (For those who don't know, this means Scottish/Celtic and German music.) There are all sorts of bands that product various "folk" songs that use traditional Celtic instrument (e.g. Tin Whistles, Bagpipes, etc.). In that category, I am currently listening to Dragonfly Redux by "An Dóchas". I have others in that category that I'm looking at purchasing. The problem that I have ends up being on the other side... What is "German" music?

I know that a lot of what we consider "Classical" music was originally composed by Germans and thus that may qualify. I know that many of the music forms that I am familiar with have bands and followings in Germany. I was just wondering if there is some music that is uniquely German that is not "Ska", "Rock", "Metal", etc? (This is not to say that I am against the more common forms of music... So if you have a recommendation, please make it.)

Looking through a Wikipedia entry on German Music, I noticed a band called "Wir sind Helden" and listened to some snippets of their work through iTunes. The surprising thing is that I recognized so many words from my language classes almost 10 years ago. Most of those that I didn't recognize at first, were refreshed in my mind when I looked them up in Google. (e.g. Hör, a command form of hören?)

Anyhoo, this is a plea for suggestions from the few Germans that I know read this blog...

PS. On a completely unrelated subject, I am now on both Xbox Live and the Playstation Network. I'm betting you can guess my user name(s).
Tags:

Sep. 7th, 2008

Seashore

Lunars and some pretty pictures...

Anathema Pictures

Yesterday, I finished the XML and Java Properties work that is necessary in order to complete the Lunars plug-in.  As per par, the structure does not exist in Anathema in order to render out the contents of this plug-in.

Sep. 4th, 2008

Seashore

It's the little things...

Just recently, it was brought to my attention that the plug-in for "Dreams of the First Age" had lain fallow for too long. I am approaching the completion of that project with a few exceptions (big surprise, I know):



  1. Lunar support, and thus their charms, are not yet supported in Anathema

  2. The new Excellencies are not yet supported in Anathema.

  3. The "Breeding" background does not count as a valid stat upon which to base a prerequisite.


Fortunately, most of these issues have been reported and are on the list for the next version of Anathema. Hopefully with that release of Anathema, you will see support for "Manual of Exalted Power: the Abyssals" and "Dreams of the First Age".




Too Human


I've noticed that most of the community of X-Box players seem to be diametrically opposed on the issue of what this games rating should be. For myself, I would agree with some who say that this game tries so hard to be everything that it fails to do anything well. At best it's rating should be meh.


Unlike other (more professional) reviewers, I was let down by the little things that I saw with annoying frequency in the game. There were too many times where I found myself adding additional words to what was said or thinking of alternative ways present what was shown. This story, while it could be compelling, was fraught with little problems that make me wonder if they just slapped the story on to be able to call it an RPG. There are dynamic elements, that attempt to ape what Bioware was able to accomplish in Mass Effect, but they felt repetitive and not at all interesting. This story is about gods living among mortals but it seemed to me that the only mortals who noticed were the guards who crouched when he approached. The dialog that happened between the mortals, likewise felt repetitive and boring because it always hovered around the same few elements. The combat and stage design attempt to capture the feel of games similar to Diablo and Diablo II but again it fails because there are so few levels and going back to "re-live" a previous level is not at all intuitive. There were places where I wondered why the designer decided to waste my time, like in the first level when you "flashback" and all you do is walk Baldur down a hall to play a movie. (Couldn't they have made that part of the movie?) The "cyber space" elements in the game seem like a joke that has a punchline you have to explain (which, of course, destroys the humor of it). Finally, is there a reason that Idunn has to inject you and dunk you in a liquid bath in order to buy or sell armor? It would make sense if you did that in order to improve you skills but not armor.




Regular Expressions


Recently, I have been studying regular expressions in an attempt to harness their power for a useful purpose. In tinkering around with them, I came up with a nifty regular expression to capture the domain name of every site that appeared in the proxy logs at my work (too many gamblers at work). Most recently, I picked up a copy of TextMate and was able to use a regular expression to eliminate some of the tedium related to making the property file that holds the page information in an Anathema plug-in.


Typically with this file, I copy the data over from a completed English translation file and them meticulously edit it. I paste the book name into the first place in each line and then I have to edit the end of each line to end in .Page=. With the regular expression support in TextMate (and probably TextWrangler as well), you can make that a bit simpler. The expression ^[^#\n] will find the beginning of every line that does not start with a # or a new line character (aka return). When you pair that with a replacement of the book name with a period (e.g. LordsOfCreation.), you can see the obvious time savings. Finding the end is just as easy just search for =.*$ and pair it with .Page= and you've just saved yourself several minutes of tedious typing.


PS. As an adjunct to this, I have begun studying Perl as it is the foundation of most Regular Expressions.

Jul. 13th, 2008

Seashore

ScribeFire Test...

Technorati Profile

Jun. 22nd, 2008

Seashore

Once upon a Riff...

Long ago back in pre-history...

The primordials formed existence from the chaos of reality. The primordials and the gods came to blows over the fate of this reality. Though the gods were ultimately victorious in the war, there was a terrible cost. Reality was shaken with their battles and servants on both sides died by the millions....




One might assume that I am writing about "Exalted" but they would be wrong. Most of that paraphrase came from the new 4th Edition DMG page 160-161. Although you can read hints of the above in the 4th Edition MM page 14, 18, 74, etc.... I find it interesting that D&D has never cared much about the state of existence before the existence of the gods. (If it was covered, it was campaign setting specific.) However, in the new version of D&D they go to some length to weave this story through at least two of the three books. It makes me wonder if there is a reason for this interesting occurence...

Jun. 10th, 2008

Seashore

The Great Iowa Flood...

Most think of Iowa as never ending series of farm fields, populated with back country hicks...  (The first is mostly true but the second is demonstrably false.)  However, as of late most of those farm fields have turned into lake country.  Fortunately for me, I'm far enough away from our creek that I've only had minor issues (which are typical for any rain issues).  Other's are much worse off and I hope that their work at sandbagging is rewarded, as it deserves.

Pictures on Picasa Web

BTW:  It was starting to rain again when this pictures were taken (you may be able to see it in some of the images. 

May. 25th, 2008

Seashore

Dreams of the First Age has and is yet to arrive...

I got my copy of "Dreams of the First Age" on about Wednesday and have been perusing various bits of the included texts. As might be guessed, I'm currently working on a plug-in for this book set. Currently, I have most of the "charms" done for all the Exalt groups (this currently excludes Knacks and Excellencies).

May. 19th, 2008

Seashore

(no subject)

Yushan Icon

I thought that everyone might be amused by my most recent (and relatively pointless) distraction. I'm also fishing for comments, if you desire to opine.

Hopefully, I will be getting my copy of "Dreams of the First Age" soon. So that I can get to work on the new charms contained therein.

Tags: ,

Apr. 19th, 2008

Seashore

Fun with SSH tunnels...

Originally, I was one of the few people that had to run around between the various physical locations that my employer maintains. Now that there has been an expansion of that group, I have begun to look for ways to minimize the annoyance and cost, of maintaining this situation. Like with nearly everything in the last couple of months, this problem was solved with scripting.

In this particular case, there are a couple of guys that don't really want to travel 1.5 hours in order to pick up a document off a computer on the remote site. This can be readily solved by using VNC but security needs to be maintained and thus some use of SSH would be required. I also don't have access to the external firewall at the remote site and thus will need to reverse the SSH tunnel.

In this case, I originally went with TightVNC but it didn't work like I had thought it would, thus I went to UltraVNC. On Windows, there isn't any other solution for SSH than the venerable PuTTY.

Local Script

Summary: The following code tests if Putty and VNC are loaded, if not it will start those programs with the appropriate options.

Details: First, I disable spurious output to the command prompt. Then, I limit the scope of the "Environmental Variables" to the current script (which is probably a waste of time). Next, I re-write the PATH variable to load the minimum needed for this script to work correctly. Then I set a bunch of "Environmental Variables" to shorten the code that I need to write. Subsequently, I test if Putty has been loaded. Then I test if it has an active connection to an SSH capable server that serves as an endpoint for the various tunnels. If any of these conditions is false, it attempts to kill off Putty and then reload it with the variables specified below. (It opens port 25901 on the end point and connects it to port 5901 on the local machine.) Next, VNC is tested in similiar ways and opens a connection to port 5901 (which gets funnelled over to the endpoint at port 25901). Then we kill the command prompts that may have been loaded.

NOTES: Ping is used to delay or "sleep" the execution of the command for a period of time required to complete the various pings. I route most of the command prompt output to the various log files declared in the "Environmental Variables". The start command is used to launch the program while letting the rest of the script continue along (it is also the reason that I had to re-write the PATH "Environmental Variable").
@echo off
setLocal

::  Set Environmental variables.

set PATH=%WINDIR%\system32;%WINDIR%\system32\wbem;%PROGRAMFILES%\Putty;%PROGRAMFILES%\TightVNC Viewer;
set PATHEXT=.exe;

::  Set Putty variables.

set KEYFILE=[Key Location]
set SSHUSER=[Account Name]
set SSHHOST=[URL | IP Address]

::  Set Logging variables.

set MAINLOG="%TMP%\mainlog.txt"
set PINGLOG="%TMP%\pinglog.txt"
set VNCLOG="%TMP%\VNClog.txt"

::  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

::  If Putty is open and running, skip to "vncstart".

tasklist /FI "IMAGENAME eq putty.exe" | findstr /c:putty.exe >> %MAINLOG% 2>&1
  if %ERRORLEVEL% equ 0 (netstat -n -p TCP | findstr /c:":22" | findstr /c:"ESTABLISHED")
  if %ERRORLEVEL% equ 0 (goto vncstart)

::  Kill existing Putty sessions, start new session and write date to log file.

taskkill /f /IM putty.exe >> %MAINLOG% 2>&1
start putty -ssh -C -i %KEYFILE% -L 5901:localhost:25901 -N -T %SSHUSER%@%SSHHOST%
echo SSH Connected @ >> %MAINLOG% 2>&1
date /t >> %MAINLOG% 2>&1
time /t >> %MAINLOG% 2>&1

::  Use Ping to cause script to pause for a few seconds for the tunnel to be established.

ping -n 16 127.0.0.1 >> %PINGLOG% 2>&1

::  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:vncstart

::  If VNC is open and connected, skip to "endscript".

tasklist /FI "IMAGENAME eq uvncviewer.exe" | findstr /c:uvncviewer.exe >> %MAINLOG% 2>&1
  if %ERRORLEVEL% equ 0 (netstat -n | findstr /c:":5901" | findstr /c:"ESTABLISHED")
  if %ERRORLEVEL% equ 0 (goto endscript)

::  Kill existing VNC sessions, start a new sesson.

taskkill /f /IM uvncviewer.exe >> %MAINLOG% 2>&1
start uvncviewer /autoreconnect 60 /autoscaling /password [password] /shared localhost:1 

::  Use Ping to cause script to pause for a few seconds before closing the CMD window.

ping -n 6 127.0.0.1 >> %PINGLOG% 2>&1

::  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:endscript

::  If CMD is open, kill all existing sessions.

tasklist /FI "IMGAGENAME eq cmd.exe" | findstr /c:cmd.exe >> %MAINLOG% 2>&1
  if %ERRORLEVEL% equ 0 (taskkill /IM cmd.exe)

::  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

endLocal
@echo on
exit


Remote Script
Summary: The biggest difference between this script and the previous is the construction of the Putty command and the restarting of uvnc_service.

Details: Putty opens port 25901 on the remote machine and then funnels that to port 5901 on the local machine. You will have to do some configuration on the VNC server so that it listens on port 5901.
@echo off
setLocal

::  Set Environmental variables.

set PATH=%WINDIR%\system32;%WINDIR%\system32\wbem;%PROGRAMFILES%\Putty;%PROGRAMFILES%\UltraVNC;
set PATHEXT=.exe;

::  Set Putty variables.

set KEYFILE=[Key Location]
set SSHUSER=[Account Name]
set SSHHOST=[URL | IP Address]

::  Set Logging variables.

set MAINLOG="%TMP%\mainlog.txt"
set PINGLOG="%TMP%\pinglog.txt"
set VNCLOG="%TMP%\VNClog.txt"

::  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

::  If Putty is open and running, skip to "endscript".

tasklist /FI "IMAGENAME eq putty.exe" | findstr /c:putty.exe >> %MAINLOG% 2>&1
  if %ERRORLEVEL% equ 0 (netstat -n -p TCP | findstr /c:":[SSH Port]" | findstr /c:"ESTABLISHED")
  if %ERRORLEVEL% equ 0 (goto endscript)

::  Kill existing Putty sessions, start new session and write date to log file.

taskkill /f /IM putty.exe >> %MAINLOG% 2>&1
start putty -ssh -C -i %KEYFILE% -N -P [SSH Port] -R 25901:localhost:5901 -T %SSHUSER%@%SSHHOST%
echo SSH Connected @ >> %MAINLOG% 2>&1
date /t >> %MAINLOG% 2>&1
time /t >> %MAINLOG% 2>&1

::  Restart VNC service...

echo Reload VNC >> %MAINLOG% 2>&1 
net stop uvnc_service
ping -n 16 127.0.0.1 > %PINGLOG% 2>&1
net start uvnc_service

::  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:endscript

::  If CMD is open, kill all existing sessions.

tasklist /FI "IMAGENAME eq cmd.exe" | findstr /c:cmd.exe >> %MAINLOG% 2>&1
  if %ERRORLEVEL% equ 0 (taskkill /IM cmd.exe)
  
::  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

endLocal
@echo on
exit

I created a "Scheduled Task" to cause this script to execute every 15 minutes during the working day. Although, I did have to modify the task after establishing it to minimize the distraction it can cause. I created a "shortcut" to the actual script and set it's properties to load in a "minimized window" and then re-write the scheduled task to execute the link. The effect is that every 15 minutes the command prompt will show up in the taskbar and then dissappear.

On the SSH endpoint server, I limit the keys to DNS names, ports and TTY access through various options added to the authorized_keys file.

Mar. 6th, 2008

Seashore

Hacking Windows, PSTools, Scripting...

In the last day or so, I've done some very interesting things with Windows XP. It started with my tinkering with a software collection called PSTools by Mark Russinovich. The most useful of these tools is "psexec" which allows me to execute commands from the "Command Prompt" across the network. One of the more significant problems with using these tools is the lack of worthwhile documentation.

I started with editing my environment to include the %PATH% to location where I store the PSTools binaries.  This is done by maneuvering to Control Panel -> System; Advanced -> Environmental Variables.  I just appended the new path to the end with %ProgramFiles%\SysInternals\PSTools; and it was done (Note:  the ; on the PATH).

You continue with configuring the terminals that the tool will be used on. First, these tools will only work across the network on Windows XP Professional computers. (You can, of course, use them directly on Windows XP Home machines.) You have to re-enable the "Classic" "Network Sharing and Security Model" to allow password access to the machine (Control Panel -> Administrative Tools -> Local Security Policy). You have to make certain that "File and Printer Sharing for Microsoft Networks" is enabled on your network device (Control Panel -> Network Connections). You also have to modify the SP2, or other, firewall to allow in traffic on port 135 (i.e. MSRPC Port) but you will want to limit the scope of the "hole" to your local subnet. Finally, you have to have an administrative account that has a password on it (without the password Windows won't allow the connection).

In my case, I created a new account on the target machines and added a password to it.  (It is worth noting for later, that this account has a space in the "User Name".)  I also took some pains to make the account disappear from the Windows XP "Welcome Screen".  For those that don't know how to do so, you first need to open the "Registry Editor".  Then maneuver down: 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\Current Version\Winlogon\SpecialAccounts\UserList
In this key, you need to make a new "DWORD Value" and give it the name of the account you want to hide (e.g. "User Name").  Now you will notice that it is not on the "Welcome Screen" but if you press CTRL+ALT+DELETE you can still access this "hidden" account.

With this being done, you can now use:

 psexec \\somecomputer -u "User Name" -p "Some Password" chkdsk /r

However, this wasn't good enough for me because I may have to manipulate several dozen machines at a time.  So now, I need to manipulate this command to allow that.  Fortunately, the author of the tool anticipated that and he allows you to import a list of computers from a file.  The problem, again, is lack of documentation for that file.  I can't say that I took a lot of time working with it but my initial attempts failed and I gave up and went to find some other way.

That is when I found the following in a post on SysInternals Fora by Karlchen:
@echo off 
for /F "tokens=1,2,3*" %%a in ('type computerlist.txt') do (
   echo Machine=%%a User=%%b PW=%%c Rest=%%d

   REM This will be the resulting psexec command
   psexec \\%%a -u %%b -p %%c [put in the remote command here]
)
This script will parse every record of the provided text file and will replace %%a with the first field, %%b with the second field, and %%c with the final field.

e.g.
somecomputer1 SomeUser1 SomePassword1
somecomputer2 SomeUser2 SomePassword2

psexec \\somecomputer1 -u Someuser1 -p SomePassword1
The obvious problem is that this script will only allow the use of one command, which is particularly unpalatable for psexec.  The less obvious problem is due to the space delimited nature of the for command and the possibility of having spaces in "User Name"  (remember the note above).

Fortunately, I wasn't without options and after a bit of hacking I came up with a derivation of the following code.

pstools.cmd
setLocal
set PATH=%PATH%;%ProgramFiles%\SysInternals\PsTools

if %PSTools% EQU psloggedon (
  for /F "tokens=1,2,3,4* delims=:" %%a in ('type "%USERPROFILE%\Desktop\computerlist.txt"') do (
    echo -- Machine=%%a User="%%b" PW=%%c Spec=%%d COM=%* --
    REM This will be the resulting psloggedon command
    psloggedon.exe \\%%a %* 2> %TMP%\garbage.txt
    echo.
  )
) else (
  for /F "tokens=1,2,3,4* delims=:" %%a in ('type "%USERPROFILE%\Desktop\computerlist.txt"') do (
    echo -- Machine=%%a User="%%b" PW=%%c Spec=%%d COM=%* --
    REM This will be the resulting pstools command
    %PSTools%.exe \\%%a -u "%%b" -p %%c %* 2> %TMP%\garbage.txt
    echo.
  )
)

endLocal
The two biggest differences are the inclusion of a : as a delimiter for the source file (i.e. computerlist.txt) and the inclusion of %* on the command.  (Aside:  The first change makes the source file look at lot like a Unix/Linux password file.)  I chose a colon as the delimiter because it is not a valid character to use in a folder and, as I'm sure your aware, every user gets a folder with their user name under C:\Documents and Settings\ .  The second change appends any additional commands to the end of the command.  This gives you the ability to use the various switches on the individual PSTools applications.

There are other minor changes that I've made to this file.  The first change includes another token in the source file which is not currently being used.  Next you can see that the path to the source has been made more relative with the inclusion of %UserProfile% .  Finally, I've redirected sterror to a "garbage" file in the directory referenced by %TMP%.

NOTE:  I'm sure that you've noticed by now, that the if command is referencing an environmental variable in order to determine which tool to call.  The reason for this will be obvious below.  Also, in the original version of the above code, I had one file for each of PSTools applications (which made it very tedious to fix errors).

The next step in this journey was to make the batch files available just like the original applications were.  Rather than add yet another entry to my %PATH%, I decided to utilize a series of  doskey alias'.  To make it more compact, I created a macro file which contains the following code:

MacroFile.cmd
psexec="%ProgramFiles%\SysInternals\PsTools\Scripts\psexec.cmd" $*
psfile="%ProgramFiles%\SysInternals\PsTools\Scripts\psfile.cmd" $*
psgetsid="%ProgramFiles%\SysInternals\PsTools\Scripts\psgetsid.cmd" $*
psinfo="%ProgramFiles%\SysInternals\PsTools\Scripts\psinfo.cmd" $*
pskill="%ProgramFiles%\SysInternals\PsTools\Scripts\pskill.cmd" $*
pslist="%ProgramFiles%\SysInternals\PsTools\Scripts\pslist.cmd" $*
psloggedon="%ProgramFiles%\SysInternals\PsTools\Scripts\psloggedon.cmd" $*
psloglist="%ProgramFiles%\SysInternals\PsTools\Scripts\psloglist.cmd" $*
pspasswd="%ProgramFiles%\SysInternals\PsTools\Scripts\pspasswd.cmd" $*
psservice="%ProgramFiles%\SysInternals\PsTools\Scripts\psservice.cmd" $*
psshutdown="%ProgramFiles%\SysInternals\PsTools\Scripts\psshutdown.cmd" $*
pssuspend="%ProgramFiles%\SysInternals\PsTools\Scripts\pssuspend.cmd" $*
The final command $* on each line causes any additional bits after the command to be passed along to the batch file on the other end.

As I'm sure that you've already deduced that even this was not good enough.  I want these macros to be launched every time that I open the "Command Prompt".  So I get to go back and edit the registry again:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor
OR
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor
You have a choice of keys you can edit to enable the autoloading functionality.  The first choice edits all the accounts on the computer at once while the second one only changes your account.  (FYI:  If you use VMWare to run your Windows installation you might have a problem if you edit HKLM.)  You need to edit the value of AutoRun to point to a new batch script that will load the macros, in this case I pointed it to %UserProfile%\environment.cmd but you can point it to anywhere your computer can access.

This environment file contains just a few commands:

environment.cmd
@echo off 
doskey /macrofile="%UserProfile%\MacroFile.cmd"
@echo on
At this point there is still one problem, I now have about a dozen batch files that I may need to edit in order to make any changes.  (Aside:  Behold my longing for symlinks in Windows XP.)  Since versions of Windows prior to Vista don't really include symlinks, so that I can use path detection (i.e. %0), I have to come up with something else.  My solution is another script.  (I know, big surprise.)

psexec.cmd
@echo off
setLocal
set PSTools=psexec
call "%programfiles%\SysInternals\PsTools\Scripts\pstools.cmd" %*
endLocal
@echo on
In the above command, you notice that I'm setting an environmental variable %PSTools% and putting a value of psexec in it.  Then I call another script pstools.cmd and append any additional bits onto that call.

After all this editing, I think that it is about time to recap what is actually happening with what I've done.
  1. Login to computer and start Command Prompt.
  2. Registry key edit calls environment.cmd
    1. doskey commands are loaded.
  3. I type psexec chkdks /r
    1. Macro is detected and calls the psexec.cmd
      1. psexec.cmd sets environmental variable and calls pstools.cmd
        1. pstools.cmd reads %PSTools% and processes it accordingly
          1. pstools.cmd reads computerlist.txt and loops the command
        2. pstools.cmd reaches the end of the script and clears local environmental variables
      2. psexec.cmd reaches the end of the script and clears %PSTools% environmental variable
  4. Command finishes.

Feb. 2nd, 2008

Mirror

Fun with Windows Scripting...

As mentioned before, my current work is pushing me into learning the "finer" points of using Command/Batch Script on Windows 2k/XP systems. On the surface, it doesn't seem that you can accomplish as much with Microsoft's scripting language as you can on a *nix platform. It may not be as richly developed as other platforms but there is a baseline of functionality contained in Microsoft's products.

For instance: on a *nix platform I might do: ifconfig | grep "inet"; on Windows a similiar command looks like ipconfig /all | findstr /C:"IP Address". (If you wanted to exactly mimic the Windows display you can append | cut -d ' ' -f 1,2 to the *nix command.)

Right now, I'm looking at having to update DNS and WINS records on about 30 machines at my work and have come up with the following code.

Change DNS and WINS Configuration

setlocal
set networkInterface=Local Area Connection
set primaryServer=SOMEIPADDRESS

:: Delete all DNS servers from system.
netsh interface ip delete dns name="%networkInterface%" addr="all"

:: Add the following DNS server(s).
netsh interface ip set dns name="%networkInterface%" source="static" addr="%primaryServer%" register="primary"
::netsh interface ip add dns name="%networkInterface%" addr="208.67.220.220" index="2"
::netsh interface ip add dns name="%networkInterface%" addr="204.127.203.135" index="3"

:: Delete all WINS servers from the system.
netsh interface ip delete wins name="%networkInterface%" addr="all"

:: Add the following WINS server to the specified connection
netsh interface ip set wins name="%networkInterface%" source="static" addr="%primaryServer%"

endlocal

Start "HG" with an Environmental Variable

@echo off
setlocal
set HLSADDR=SOMEIPADDRESS
start /D"%USERPROFILE%\Application Data" \\SOMEIPADDRESS\hg\thgg.exe
endlocal
@echo on
exit

Now it may seem really odd to start a Windows application with a Command script but this particular case is unusual. The program that I'm starting requires an environmental variable be present or it squawks about "Licensing Issues". Rather than edit the registry to supply the necessary values, it's easier to start a script that contains them and when the application quits, the variable goes with it.

The installation script that I use for "HG" is much the same as it's starter, the only significant difference is the presence of the /wait switch (e.g. start /wait SOMEAPPLICATION. I did this because "HG" requires 3 different applications be installed prior to using it and I don't want those installers tripping over each other. I also copy over some shortcuts and and afore displayed script to launch "HG".

Oh, another particularly useful Windows command if you desire use the command line to edit some things that can only be done by the Administrator is: runas /user:"ADMINACCOUNT" SOMEAPPLICATION. I tend to use CMD.exe as the application but you could use it to launch nearly anything.

Jan. 31st, 2008

Seashore

The Scriptorium and Linux

Well for the last week or so, my life has been full of typing. A few dozen Windows command scripts here and a dozen *nix shell scripts there. Most of this is an attempt to reduce the unorganized largessness of working where I do to something more managable.

On Windows, they have a CMS application which requires about 4 other applications to be installed before you can use it. I have a nifty script that starts each installer, waits until completion, continues to the next installer (rinse and repeat), it copies over an icon and another script that sets an environmental variable (required for licensing), and finally, if necessary, edits an INI file to allow managerial access to the application. Another set of scripts allows a specific application to be run with "Administrator" priviledges so that it can update it's data files. Still another series of scripts set's up a kind of backup scheme using "xcopy" for some of their departments.

On the Unix front, I've made a nifty script that allows me to easily log into the various *nix systems that I use on a daily basis.

Script 1

#! /bin/bash

# This little script is designed to allow me to quickly switch between the
# various Linux boxes on the network without causing me any problems with
# the normal use of the SSH command.

SSH=/usr/bin/ssh

if [ $# -lt 2 ]; then
SSHADDR=$(printf $1 | tr [:upper:] [:lower:])
fi

case $SSHADDR in
"home" )
$SSH ME@my-imac.local;
;;
"wlo" )
$SSH -i $HOME/.ssh/KEY2 ME@111.93.84.115;
;;
"wlo2" )
$SSH -i $HOME/.ssh/KEY2 ME@111.93.84.15;
;;
"cp" )
$SSH -i $HOME/.ssh/KEY2 ME@111.110.93.50;
;;
* )
$SSH $*;
;;
esac


Now, instead of writing over 24 characters, I type 7 or 8 characters and I don't forget to remember the "-i" option for my alternative key. If necessary, it also allows the normal functioning of the ssh command. Although, I do wish there was a better way of lower casing just the custom options. (i.e. I also have the following loading with my shell (zsh) alias ssh='sh $HOME/Applications/ssh.sh'.)

The company I work for finally decided to spring for an actual server box (rather than using my brother's Compaq PC) to run the necessary network services. The new box is a Dell SC1430 with: 2x 1.6Ghz Xeon Dual Core CPU's, 4Gb of RAM (SME is 32bit only), and an 80Gb HD. To that we added some equipment from Newegg: 2x 1Tb Hitachi HD's, 1 Intel Dual port PCI-Express card and an 3.5 to 5.25 HD bracket. The initial setup of SME Server was nearly trivial but that may be because I didn't initially connect the additional two drives. After setup, I put in the two terrabyte drives and attempted to RAID-1 them together. Thus, I got to meet the brick wall head first. Apparently, no one on the community site has ever attempted to add more drives as a RAID array. I thought, at one point, that I got it working but at least some of the SME software wasn't detecting it correctly and I decided to start over.

The end result of my tinkering and research has revealed that the following commands seem to correctly create the array in SME Server.

Script 2?

NOTE: Not yet feature complete.

mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm --detail /dev/md3
printf "EJECT THE CD-ROM\!\!\!\a\n"
pvcreate /dev/md3
vgcreate -s 16M lvm-raid /dev/md3
vgchange -a y lvm-raid
vgdisplay /dev/md3 | grep "Total PE"


Total PE / Size XXXXXX / YYYY

lvcreate -l XXXXXX lvm-raid -n bigdisk
mkfs.ext3 /dev/lvm-raid/bigdisk
mkdir /user_files
mount /dev/lvm-raid/bigdisk /user_files

mv /etc/mdadm.conf /etc/mdadm.conf.bak
printf "DEVICE partitions\n" > /etc/mdadm.conf
printf "DEVICE /dev/s[bc]1\n" >> /etc/mdadm.conf
printf "ARRAY /dev/md2\n" >> /etc/mdadm.conf
printf "ARRAY /dev/md1\n" >> /etc/mdadm.conf
printf "ARRAY /dev/md3 devices=/dev/sdb1,/dev/sdc1\n" >> /etc/mdadm.conf


Now you have to edit /etc/fstab to add /dev/lvm-raid/bigdisk /user_files SOME TEXT 1 2 .

In closing, I've found an interesting book that deals with shell scripting by O'Reilly, obviously, called Classic Shell Scripting. Microsoft has also been kind enough to enable me to purchase "Super Mario Galaxy" and thus I may be joining the RSI club.

Updates:Code tweaking.

Jan. 17th, 2008

Mirror

Does it have that new job smell...

Well, I now have a new job working as a one man IT department for a car dealership. My job is to take the place of the three guys that moonlighted as IT experts for the business. I'm still in the process of assimilating how their network is setup and how to make it better (which is difficult because a vendor effectively controls the network). At the moment, I'm migrating them to use and secure their wireless AP's. Previously, there were only minimally using their wireless, due to security issues (ironically enough). I'm also working to get one of their decomissioned servers (an IBM eServer) setup as a workgroup server to store and backup their documents (using SME Server). I'm implementing a "backup" system for some of their important "side" businesses. (i.e. A Windows batch script that uses xcopy to transfer files to another system in the workgroup.) I'm also in the process of researching a new software piece that is going to be used in the Body Shop. (Which, of course, has no publically available documentation and it seems as though all the sellers of this software seem to work in only one speed, 1 week behind.) The only problem, which might be a bit silly, is that I don't think that I'm working fast enough.

This was particularly annoying yesterday (01/16), I went out to setup an AP at the other main site. I made the 30m trek there and got to work setting up the the router with the static IP's that they use for their network. After updating the firmware, setting the SSID, limiting the acceptable MAC addresses, and adding an WPA encryption key; an hour had passed doing this. Then I found out that unlike many of competing products, the D-Link DIR-615 router wouldn't act as an AP, this took another 45 minutes. (i.e. Acting as a bridge to the wired network, no NAT.) So I made a trip into the nearest big city and visited the local BestBuy but they were out of what I needed. Fortunately, right across the street was a Staples that had what I needed and it was for a cheaper price. It took 20m to get to BestBuy, 10 minutes to cross the street to Staples, and another 10 minutes to get back to the worksite. Once there, I ran into some interesting problems with the AP. Annoying enough, Linksys set their wireless AP to a static IP (which is incompatible with this network) and they don't readily tell you what the IP is for that device, this took 15 minutes. I finally got it setup with the correct IP information and plugged it into the network to verify it would work, this took another 15m. (Obviously, it didn't.) For whatever reason, the AP wouldn't connect to the network and so I changed it's IP and got it working. Now that it was working correctly, I moved it to it's new home and verify that it has connectivity there. I didn't and I realized that they didn't connect up all the jacks (which was a good choice but I wish that I had been told), this took 10 minutes of running around. Now, I had to program a wireless diagnostic device to use the AP (this allows the tech to quickly and without the 25ft wire diagnose and update GM cars). Unfortuantely, for me, they had lost the USB cord that would allow me to do that. So, I had to make another trip into the nearby city and get one, another 25 minutes of time wasted. I finally got back and programmed the device with the necessary information. The programming tool told me that it had an excellent connection to the AP, which is obvious since it was about 10 ft away. Now, I connected it to the car and low and behold, it didn't work. Ok, back to the tool and try to figure out what went wrong. I spent the better part of 30 minutes trying to get the device to work and came to the conclusion that it just was refusing to store the SSID of the network and the key to get on it after it was disconnected from the computer. So at the end of about 6 hours of time, I have setup an AP but otherwise, I've wasted my time. (To a certain extent, it also feels like I'm cheating my boss because I didn't get it done as quickly as I had intended to.)




On another related topic, this job has provided with the "excuse" and means to pick up a fairly nice MacBook Pro. It's the high-end 15" with a 250Gb HD. I'm adding to it 4Gb of RAM, VMWare Fusion, and Windows XP Pro. One nice thing is that I don't need to buy a case because during my work at the local Apple dealer, I managed to get one for free as a "sample". (Though I do have to use two cases in order to make my current MacBook fit.) The laptop is expected to ship by he 22nd (I hope for sooner) and the rest of my phat loot, should be here within a week. It's going to be interesting setting that up.
Tags:

Jan. 3rd, 2008

Seashore

Will it Render? Yes, it will!

Over the past couple of days, in what some might call a fit of insanity, I have done a significant overhaul to the "charmreview-xmlns.xsl" file. As you may be aware, this is a tool that I use to proof what I've made into XML. It is designed to render out the charm XML into a format that is nearly identical to what White Wolf uses in their books. Until recently, it was only capable to rendering out Martial Arts and other similar types of charms (i.e. no excellencies as prerequisites or excellencies in their own file). That has now changed.

The current version of "charmreview-xmlns.xsl" uses 3 major templates to render out the various charms. The first establishes the basic parameters for the HTML that will be viewed in a web browser. The second two actually render the contents of their respective charm types (i.e. <charm /> or <genericCharm />). In order to reduce the bloat of code in the XSL, the remaining 9 or so templates are called to render their specific parts of the XML.

Example:

<genericCharm id="Something" exalt="Someone" />

<charm id="Something" exalt="Someone" group="Somegroup" />


In both of these cases, the "charm" has an attribute id which can be made more generic and used for both types of charms. Which, of course, begs the question: How?

The answer is <xsl:template match="genericCharm" /> or <xsl:for-each select="charmtype" />, which is either part of the template or it surrounds the function that calls the template. These effectively eliminate the need to consider either of the root XML elements because we are already fixed on a specific element (also called a context node).

What is even cooler, is that this XSL can be applied to [info]urskr 's monolithic charm files and you will get a similar result.

Some beautiful code follows:
    <xsl:template match="chrm:genericCharm">
<xsl:call-template name="Line_1"/>
<xsl:call-template name="Line_2"/>
<xsl:call-template name="Line_3"/>
<xsl:call-template name="Line_4"/>
...

<xsl:template match="chrm:charm">
<xsl:call-template name="Line_1" />
...

<xsl:template name="Line_1">
<xsl:element name="p"><xsl:element name="b">Name: </xsl:element><xsl:value-of select="@id"/></xsl:element>
</xsl:template>


In closing, this process also taught me that the xsltproc program included with OS X 10.5 is much better at helping me catch my errors in XSL files than either of the web browsers that I use for charm making.

PS.  Oh, for most intents and purposes, the XML for the Lunar's plug-in is done.
Tags: ,

Dec. 30th, 2007

Mirror

Sagacious updating of progress...

Updates:
  • Modified anathemaTool.sh to allow in-place validation of files and fixed an issue with the find command.
  • Added 90% of Lunar charm trees (less Wits and "Lunar Hero Style")
  • Made various alterations to charms.dtd and charmreview-xmlns.xsl .
  • Added more information about plugin-fragment.xml to plug-in documentation project.

In Progress:
  • Lunar plug-in:
    • Finishing up coding for remainder of Lunar charms.
    • Read through Lunar charms and add "Coding" comments to charms when necessary.
    • Alter plugin-fragment.xml to incorporate file and directory listings for Lunar charm files.
    • Alter language property files for new charm tree.
  • Add charm XML information to plug-in documentation project.

The first list is what I've been up to in the last couple of weeks. I've got quite a bit of XML coding done for the new plug-in. During this process, I've had to update various supporting files to allow things that are done with charms in the Lunars book. Charms.dtd was updated to allow for the use of "Attribute Excellencies" and I fixed a minor error with the default speed for charm based attacks. Charmreview-xmlns.xsl was updated to properly display "Excellencies", number of required "Excellencies" and I've added in proper support for the "dramatic action" and "long ticks" based charms. (Previously, neither of these were being displayed at all.)

All this coding has reminded me of a few things that I've added to my charms as a "safety net" that need to be properly documented when I describe charm XML on the documentation project. In specific, Anathema doesn't display the following in the charm viewer:
<charmtype type="Simple">
<special turntype="DramaticAction" />
</charmtype>

If you don't include both speed and defense numbers (these can be the default speed="6" defense="-1"). This is something that I'd forgotten about because my charms.dtd file was "shielding" me from this issue. Given this, I've went back through all my charms and have updated them so that they can be used without the DTD. I've also eliminated some <special /> tags from Simple charms that just listed the default values and nothing else (they were superfluous).

In the second list, both of the charm trees sould be fairly easy to convert to XML because they are both relatively small. The rest is going to take some time.

PS. Does anyone have any thoughts on what I've done thus far for plug-in documentation? See Anathema Development for link.
Tags: , ,

Dec. 16th, 2007

Seashore

Plug-in Updates...

I've updated the following items on Yushan:  book_scrollofthemonk, book_MoEP-Sidereals, and anathemaTool.sh.

Due to versioning on Google Code (i.e. the inability to delete old plug-ins after a certain date), I've encapsulated all the files inside of zip files.  If you are using OS X 10.5 "Leopard" you may have to use something other than the built in unarchiving program because it de-JAR'd my plug-in as well.

What I see when I decompress the zip file.

Dec. 15th, 2007

Seashore

Well, that was enlightening

According to my new tool, I've made some mistakes in both my DTD and some of the Sidereals XML.  The DTD errors are related to not having registered charm id's as an ID, as defined in a DTD, and I also left out "StealthExcellency" as an entity.  I also had some minor typo's in the Melee and Ride Sidereal trees, which have now been fixed.

The final remaining problem is related to the structure of the XML and is not fixable by me.  This is caused by the differing layouts between XML files.  In some, the <combo /> element comes before <duration /> but in others it is different.  In order to make this DTD work for most Anathema XML files, I have to leave it as it currently is.

What this means is that if you use the command detailed in my previous post and see errors related to the DTD not being "determinist", you can safely ignore it.

Now to incorporate it into anathemaTool.sh.

Update:  I spoke too soon, after testing my other plug-ins, I've found a few more errors.
Tags: ,

Previous 20

Advertisement

Customize