2009-10-15

RAID failure, loss of data and anger

RAID is not a good alternative to backing up data. Data may become damaged or destroyed without harm to the drive(s) on which they are stored. For example, some of the data may be overwritten by a system malfunction; a file may be damaged or deleted by user error or malice and not noticed for days or weeks; and, of course, the entire array is at risk of physical damage.

Note that a RAID controller itself can become the single point of failure within a system.

2009-01-15

Launch TightVNC using the Computer Name - or - How to Get IP from Computer Name in MS-DOS Batch

First, knowing the name of a computer, we want to get its IP. The script below does it for you. I called it 'GetIpFromName.bat' and I put the IP in a variable called 'GetIpFromName':.

Then we need to call 'GetIpFromName.bat' and launch VncViewer. I called the script 'StartVncViewer.bat'.

Finally, if I often need to access a computer called, say, Bambi, I create a script called 'VncBambi.bat' on my desktop.

Update 2013: consider tweaking variables for the appropriate viewer: legacy (vncviewer.exe) vs. 2.x+ (tvnviewer.exe)

2009-01-05

Work around AutoIT stdin limitation

The fastest way to implement a small script and to process a file (or a chunk of data) is to use the standard input rather than file-handles.

1/ It is easier to redirect a file instead of providing parameters to a program.

2/ When you use redirections, the operating system works for you: it opens the file and feeds the program with its content.
C:\> AutoIt3.exe DiffPrettyfier.au3 < MyInput.txt > MyOutput.txt

The content of the script is straight forward:
$myInput = ConsoleRead()
; do something here
; (...)
ConsoleWrite($myOutput)
But there is one problem that makes this a bit harder: AutoIT 'ConsoleRead' doesn't handle input bigger than '65535' characters. So here is a little workaround: use the function 'StdinRead' below instead of 'ConsoleRead':

;-----------------------------------------------------------------
; Name .........: StdinRead
; Description ..: Wrapper for ConsoleRead because it doesn't
; handle big files
; Warning ......: This is a workaround but it has limitations too,
; I used a big file to test this function but it
; might fail on a VERY big file (eg. if the file
; contains 2 147 483 647 characters)
; original big file tested: 18 030 950
; biggest string size allowed: 2 147 483 647
; Parameters ...: n/a
; Return .......: String read on STDIN or empty String "" if
; nothing found on STDIN
;-----------------------------------------------------------------
Func StdinRead()
Const $MAX_BUFFER = 65535
$eofReached = False
$fileContent = ""
While Not $eofReached
$buffer = ConsoleRead($MAX_BUFFER)
If @error Or $buffer = "" Then $eofReached = True
$fileContent &= $buffer
WEnd
Return $fileContent
EndFunc ;==>StdinRead


NOTE: For "ConsoleWrite" to work as expected (redirecting output to stdout), you need to compile the script using the "/console" switch.