Friday, November 18, 2005

MAC Watch

I'm currently saving up to treat myself to a shiny new Mac; I've always wanted one and I have now "got permission" to buy one thanks in no small part for my willingness to part with silly amounts of money for a Canon EOS 20D, probably one of the coolest digital SLRs that you can buy without selling 2 or three internal organs.

My initial plan was to get a mac mini and convince the wife to scrap the desktop PC, its just too big and we don't really need all the processing power and storage that I have accumulated over the years.

I thought a Mac mini would fit our needs perfectly and increase the workflow of our little home photography studio. Namely by letting me create a little Automator program that when a photo was dropped on to it, it would rotate to portrait mode, resize to 10x15 or whatever other sizes I decide I want to print on, set the resolution to 300DPI and then print it. This would remove about oh lets say a half dozen steps in photoshop.

Then this interesting article dropped in my inbox and changed all that
http://www.thinksecret.com/news/0511intelibook.html

Now im swinging to getting an iBook and just using it as a workstation with better portability, I would of course be wanting to get another one, just so that if I have it with me, there is still one at home/with the wife.

My wife doesn't use the PC that much anyway, a bit of light photoediting and printing, webcam chats with her dad in Thailand and stepsister on an island in the Philipines, iTunes, some internet browsing and thats about it.

I only need some Linux programs, Dreamweaver and a Microsoft remote desktop connection and I am able to work from home on whatever I need to.

Oh wait, all of those are available for OS X, and even if they weren't I have an old Sony VAIO that can be trundled out when I absolutely, positively want to(have to) gouge my eyes out on Windows 2000 with 64MB RAM.

I'll keep this updated with how the quest for mac progresses, and how much I love/hate it when it arrives.

Thursday, November 17, 2005

Battyness today!

Again, some more .bat scripting to make my life a bit easier!
This time its SQL Enterprise Manager that is misbehaving; for whatever reason the wrong DLL's get registered and when you try to connect to any SQL database server you get and OLE 13686 error saying that you must upgrade Enterprise manager.
What you do is unregister some DLLs, copy the proper ones back in from the SQL install media and then re-register the new DLLs. IN my case the install media lives on a network drive.

@ECHO OFF
:: SQLSRVR.bat
:: Written by Daniel McLaughlin
:: http://danmacs.blogspot.com
ECHO Mounting Network Share as Local Drive
NET USE t: \\NET IP ADDRESS\share\Applications\sql2000\x86\binn /PERSISTENT:NO

CLS
ECHO *********************************WARNING*********************************
ECHO * You Should only run this if you are receiving the OLE 16386 Error *
ECHO * This assumes that you are using the default directory structure *
ECHO * i.e. .../program files/Microsoft SQL Server *
ECHO *********************************WARNING*********************************
ECHO.
ECHO.
PAUSE
ECHO.
ECHO.
ECHO *********************************INFO*********************************
ECHO You Will now unregister the DLLs invlolved with
ECHO SQL Enterprise Manager 2000
ECHO Five (5) Information boxes will appear, click OK on each
ECHO *********************************INFO*********************************
ECHO.
ECHO.
ECHO.
PAUSE

CD "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"

REGSVR32 /u dtsui.dll
REGSVR32 /u sqlns.dll
REGSVR32 /u sqldmo.dll
REGSVR32 /u sqllex.dll
REGSVR32 /u sqlmmc.dll

ECHO.
ECHO *********************************INFO*********************************
ECHO You Will now re-register the DLLs invlolved with
ECHO SQL Enterprise Manager 2000
ECHO Five (5) Information boxes will appear, click OK on each
PAUSE

ECHO STEP 1
ECHO.
ATTRIB -R "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\dtsui.dll"
ATTRIB -R "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlns.dll"
ATTRIB -R "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqldmo.dll"
ATTRIB -R "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqllex.dll"
ATTRIB -R "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlmmc.dll"

ECHO STEP 2
ECHO.
DEL "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\dtsui.dll"
DEL "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlns.dll"
DEL "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqldmo.dll"
DEL "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqllex.dll"
DEL "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlmmc.dll"
CD \

ECHO STEP 3
ECHO.
XCOPY "t:\dtsui.dll" "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"
XCOPY "t:\sqlns.dll" "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"
XCOPY "t:\sqldmo.dll" "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"
XCOPY "t:\sqllex.dll" "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"
XCOPY "t:\sqlmmc.dll" "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"

cd "%1:\Program Files\Microsoft SQL Server\80\Tools\Binn"
REGSVR32 dtsui.dll
REGSVR32 sqlns.dll
REGSVR32 sqldmo.dll
REGSVR32 sqllex.dll
REGSVR32 sqlmmc.dll


ECHO File Copy Successful
ECHO Thank You For Using this utility
net use t: /d
PAUSE
cd \
CLS


To use this script, CD to the directory where it lives and run it from the command line with one additional parameter, the drive that Enterprise Manager is installed on. so for example

c:\> sqlservr.bat c


Wednesday, November 16, 2005

Full of scripty goodness

This is one of the batch scripts that I wrote today, basically what it does is log in to a samba server that is doing NT Authentication with Active Directory, takes user input to specify the source folder on the remote server and the target folder on their local machine. To do this it creates a temporary mapped drive on their local machine that is destroyed when the script runs through, its not a persistent connection so if they screw up or kill the script it won't leave the mapped drive sitting on their machine.

The specification I was given for this was:

"I need to copy an entire folder down to my laptop so that if i am travelling it will have the latest documents in it,
I want to be able to specify the directory to copy the files into and I don't care if it overwrites the existing files/folders"

Why they couldn't just copy the files down through Windows Explorer I will never know, but it filled an hour or so and I know lots more about batch scripts than I did before! I probably would have written it so that it didnt ask for any user input apart from the username and password but that would only have worked if the target and source directories were constant, and obviously they won't be.

This would probably have been much simpler to write and much more powerful in Linux (rSync goodness abound!) but this way it minimises the amount of additional software and extra permissions that people need (cygwin on their local machine and a login on the remote linux box).

I might in the future set it up so that the user can specify the remote server as well and navigate through the directory structure.

There are some limitations on its behaviour, I'm still discovering some of the stranger things that it does, i.e. if you are a smart arse and feed it a file within a folder as the target (i.e. work/thisisafile.xls) it will create teh work folder and then another folder beneath it called thisisafile.xls and this folder will contain a file of the same name. This shouldnt be a problem but I would rather it didnt do it. It serves its purpose in the mean time and it may never be modified again but it is something that would annoy me immensely.

@ECHO OFF
:: copydir.bat
:: Written by Daniel McLaughlin
:: http://danmacs.blogspot.com
SET SOURCE=
SET TARGET=
ECHO Mounting Network Share as Local Drive
ECHO.
ECHO Enter your username and close by pressing Enter, F6, Enter.
ECHO You Will Be Prompted for your NT Password
FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET USERNAME=%%A
NET USE t: \\Target IP Address OR Hostname\shared dir * /USER:
DOMAIN\%USERNAME% /PERSISTENT:NO
CLS
ECHO.
ECHO Directory Listing for
"Description of the target folder"
ECHO.
dir /A:D /W "t:\
Target folder\"
PAUSE
ECHO.
ECHO Type in the source directory path
ECHO *********************************WARNING*********************************
ECHO * Specifying a null directory will copy the ENTIRE folder *
ECHO * *
ECHO * If you accidentally specify the entire folder press CTRL +C *
ECHO * The Temporary Drive (t:) Created will be removed on your next reboot *
ECHO *********************************WARNING*********************************
ECHO.
ECHO End directory entry by pressing Enter, F6 then Enter again.
ECHO.
:: Only one single command line is needed to receive user input
FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET SOURCE=%%A
:: Use quotes if you want to display redirection characters as well
CLS
ECHO.
ECHO Type in the ***full*** target directory path
ECHO i.e. c:\documents and settings\user\my documents
ECHO Files will be put in a subfolder with the same name as the target dir.
ECHO End directory entry by pressing Enter, F6 (or Ctrl+Z), Enter.
ECHO.
:: Only one single command line is needed to receive user input
FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET TARGET=%%A
CLS
ECHO *********************************INFO*********************************
ECHO You Have Specified Source(remote) Folder %SOURCE%
ECHO You Have Specified Target(local) Folder %TARGET%
ECHO If you accidentally specify the wrong folder(s) press CTRL +C
ECHO The Temporary Drive (t:) Created will be removed on your next reboot
ECHO Otherwise

PAUSE
XCOPY /-Y /W /E "t:\
target folder\%SOURCE%\*.*" "%TARGET%\%SOURCE%" /s
ECHO File Copy Successful
ECHO Thank You For Using this utility
PAUSE
net use t: /d
CLS

Obviously you wont be an eejit and just copy this into notepad and expect it to run, there are a few parts that you need to edit in order for it to work for you, these are in italics and bold just so that they are easy to spot.

Monday, November 14, 2005

del.icio.us

I have been using del.icio.us for a while now, I found it by accident and thought it was a fantastic tool, I recommend it to anyone who will listen and anyone who gives it a go tends to keep using it.
It works for me because i could be at any number of PCs and still have access to my favourites list.
I know I could set u p a HTML page with my bookmarks on it, but why would I do that when someone else can do it for me, and I can share what i found with other people!
There is also the "popular" section where you can see the most bookmarked pages over a period of time.
I stumbled across tagrolls on their site and I thought I would use it now to show people exactly what i might be looking at at any one point in time. Unfortunately, it doesnt work with blogger as you can't incorporate javascript. Pants.

Wednesday, November 09, 2005

protect web directories using .htaccess

Here's a tutorial on how to set up password protection under Apache 2.0.54 and Windows 2000
it takes about 5 minutes to set this up and provides an adequate level of protection for files that are web accessible anyway!

1. Open up a command prompt and navigate to your apache2/bin directory, it will be c:\program files\apache group\apache2\bin if you used a default apache installation
2. Type the following command "htpasswd -c filename username" where you choose the name of the password file (remember what you called it) and the name of the user that you want to add to the user list, you will be prompted twice for a password
3. Copy the new password file to a directory outside your web root, you dont want anyone being able to see it
4. You now need to edit your httpd.conf file, if you search for the following string "FileAccessName" that will take you to the correct place in the file. Create a new line after that section and add the following text:

<directory>
AllowOverride All
Options None
Order deny,allow
</directory>

Where protected directory is the full path to the directory that needs to be password protected i.e. "c:/webroot/site/www.home.com/securearea"
5. Browse to that directory and create a new text file called htaccess.txt, inside this add the following text

AuthUserFile "path/to/your/password/file"
AuthName "The Message you wish to appear on the prompt that pops up"
AuthType Basic

<Limit>
require valid-user
</Limit>

6. Save this and rename it to .htaccess using your favourite editor (NOT NOTEPAD!!!)
7. Restart apache and try to browse to your newly protected directory, you should be presented with a dialogue box asking you for a username and password (the ones you created earlier!)

This will give you rudimentary protection for the files contained in that directory but there is much more that htaccess can do, for example it can limit access to a specific IP range, so say you have an internet site that is part intranet, you could limit access to the intranet subsection so that it is only accessible to users that have a 10.0.0.0 or a 192.0.0.0 IP address, i.e. those users on the internal network.
I can't cover all the possibilities that this presents, there are simply too many permutations, but there is plenty of help out there, remember google is your friend!