Chris Nizzardini, Salt Lake City Utah, Web Developer Specializing in LAMP+Ajax Since 2006

My Blog

Here is my awesome blog. You can find information on programming, linux, documentation, tips for code and database optimization, my thoughts and rants, and whatever else I feel like sharing. Feel free to contribute to the blog by posting comments and asking questions.

Archive for February, 2007

Linux ifconfig / route commands

Posted by chris on February 18th, 2007 Comments (4)

Add a static IP Address:
ifconfig [interface] [ip address] netmask [subnet address]

Add a default gateway or route:
route add default gw [ip address]

In Linux ()

Using SYSPREP to Create Windows XP Images

Posted by chris on February 16th, 2007 Comment(1)

I frequently forget the steps involved in Sysprepping a box. The easiest way to prepare a machine for imaging with sysprep can be broken into 4 steps.

Step 1. Creating the SysPrep Folder
Step 2. Run SETUPMGR.EXE
Step 3. Customer Software
Step 4. Sealing the Work Station

Step 1. Creating the SysPrep Folder

Create a folder called C:\SYSPREP and copy the following files from a Windows XP Pro installation CD to it:

D:\SUPPORT\TOOLS\DEPLOY.CAB\FACTORY.EXE
D:\SUPPORT\TOOLS\DEPLOY.CAB\SETUPCL.EXE
D:\SUPPORT\TOOLS\DEPLOY.CAB\SETUPMGR.EXE
D:\SUPPORT\TOOLS\DEPLOY.CAB\SYSPREP.EXE

Step 2. Run SETUPMGR.EXE

Double-click C:\SYSPREP\SETUPMGR.EXE

Click Next at the welcome screen. On the next screen make sure the Create a new answer file option is selected and click Next.
At the product install section ensure Sysprep Install option is selected and click Next.
At the platform screen make use the Windows XP Professional.
At the License Agreement screen select No, don’t fully automate the installation option and click Next.

Step 3. Customer Software

Here you can select various options such as name, organization, display settings, time zone, default administrative password, langue etc…
When done click Finish.

Sometime it looks like the window is hanging after you’ve clicked finish, if it this window remains for longer than 20-30 seconds just click cancel.

Step 4. Sealing the Work Station

Double click the C:\SYSPREP\SYSPREP.EXE icon to begin sealing the workstation.
At the windows system preparation tool screen click OK.
At the system preparation tool screen enable the MiniSetup and ensure that shutdown is selected and then click Reseal.
At the prompt to continue with current settings and regenerate the SIDs click OK.

At this point sysprep will seal the system and shut it down. Now utilize your imaging utility (ghost, acronis…) to create the image.

In Software ()

Get active directory ldap attributes from the command line with ldifde

Posted by chris on February 14th, 2007 Comments(0)

Technet gives the following description of this command. “Creates, modifies, and deletes directory objects on computers running Windows Server 2003 operating systems or Windows XP Professional. You can also use Ldifde to extend the schema, export Active Directory user and group information to other applications or services, and populate Active Directory with data from other directory services.”

I typically use this to find out a specific ldap attribute which is useful when I’m writing VB scripts that loop through each user object in active directory and change attributes. This command is run from the windows command line. Here are some examples.

Display ldap attributes for all user objects within active directory:
ldifde -d “cn=Users,DC=3rdleveldomain,DC=2ndleveldomain,DC=com” -f con

Display ldap attributes for a single user object:
ldifde -d “cn=Firstname Lastname,cn=Users,DC=3rdlevel,DC=2ndleveldomain,DC=com” -f con

Further details on this command are available at Microsoft Technet

In Software ()

WaitForExit method, running command line args in c#, and other hacks

Posted by chris on February 12th, 2007 Comments (3)

I’ve been writing an application that allows me to easily deploy files to our corporate website. Since I had to build under the guidelines of my boss and this is my first c# project I needed to do some hacking that most experienced c# programmers would laugh at.

The application does a few things. One it allows you to select any number of files or folders and click a button to automatically add them to zip file via winzip, open an sftp connection with SecureFX, and make an ssh call using plink for additional commands which unzip the file and sync the files across multiple web servers. . I needed a way for my ssh function to wait for my sftp function, and for that to wait for my zip function to complete.

I use the Process.Start method to access the windows command line and pass arguments. Then I used the WaitForExit method to stop any further code from executing until the current process completed. Both are in the System.Diagnostics namespace.

private void ZipIt()
{
Process oProc = Process.Start("cmd.exe", "/c wzzip.exe -p -r -yb c:\\temp\\corpsite.zip c:\\temp\\filepush\\>c:\\temp\\zip.log");
oProc.WaitForExit();
}
 
private void SFTP()
{
Process oProc = Process.Start("cmd.exe", "/c sfxcl.exe c:\\temp\\corpsite.zip sftp://user:pass@ip.address>c:\\temp\\sftp.log");
oProc.WaitForExit();
}
 
private void SSH()
{
Process oProc = Process.Start("cmd.exe", "/c plink.exe -ssh -batch -l user -pw pass ip.address C:\\ppmd\\CorpDeploy\\script\\MoveFiles.bat>c:\\temp\\ssh.log");
oProc.WaitForExit();
}

If you’re more interested in running command line apps and passing arguments to them with c# then you’ll need to copy the exe file to your system32 folder. I still have not figured out a way to hide the command window when these processes run. If you know how to do this please add a comment. Thanks for reading.

In Programming (, , )

What to Write?

Posted by chris on February 12th, 2007 Comments(0)

At work right now so I’ll make my first blog post here short. I’ll use this as a place to store important information, specifically technical information related to I/T (programming functions, linux how to’s, and windows stuff). Basically this will be my fail-over when my brain crashes trying to remember something.

Got a lot of stuff I’m working on so I should start doing lots of blog entries shortly.

In Rant ()