Archive for the ‘Operating Systems’ Category.

Utah Open Source Conference 2010

Hey all,

The Utah Open Source Conference 2010 was pretty fun.  It was really my first open source conference.  Yes, I have been into open source for 10 years, specifically FreeBSD, but somehow I haven’t really attended the conferences.

I will probably attend conferences more often.

What was there about FreeBSD?

PC-BSD and the folks as iXSystems sent me with some swag.  Howard Logsdon helped me man the GUBUG booth.

There was a great presentation on FreebSD Jails given by Chris Edwards. (http://www.utosc.com/presentation/157/) Supposedly they are going to post a recording of the presentation. Until then, check it here: (http://wiki.zelut.org/doku.php/presentations:freebsd-jails)

Who else was there?

So Novell SUSE brought some nice laptop bags, and they were pretty good.  I have a nice Ogio laptop back pack, so I am giving this laptop bag to my wife.  It is just big enough to fit her 17″ HP laptop.

There was Fedora, Ubuntu, KDE, and GNOME.  There was a boot on XDMC and MythTV.

There was a very cool company there called Fusion-IO.  They have an awesome hard drive, though they are not cheap. 7k for the cheapest drive. But for some companies, it would be worth it.
When is the next Conference?

You can go here to see upcoming events: http://www.freebsd.org/events/events.html

There is the Meet BSD California 2010 conference November 6 and 7th.

To see when the next Utah Open Source Conference is you should go to the site and register so that when the date is announced, you will be informed.

VirtualBox: It seems ready

Ok, so because my work has given me a license to VMWare Workstation, I have never really gone to the trouble of using VirtualBox.

But I really want to move to use FreeBSD (well, PC-BSD) on my laptop but I have to have a Windows 7 box for work.

So I had Windows 7 with PC-BSD in a VMWare Virtual Machine.

However, I am switching that as we speak.

I now have PC-BSD installed as my primary operating system, and Windows 7 in a VirtualBox Virtual Machine.

There are some features we use at LANDesk a lot, such as many snapshots, and PXE booting, and more.  I will test and follow-up on whether this is a good solution for me.

Blogilo: Writing a post using Blogio, a KDE app on PC-BSD

Hey all,

I decided to try a post using Blogio. Supposedly it is a nice tool where I can write my blogs offline, save them locally, and post them when I can.

So lets see how some of the features work.

This is a heading 1

However, after creating heading 1 and then hitting enter, it did not make the next line’s type to Paragraph. I changed it to paragraph and it was still wrong. I had to click Html editor and then click back to the visual editor to make this work.

This is a heading 2

Same problem with heading 2.

Here is a quote

Ending quote was easy. Just hit the quote button again with the mouse.

  1. This is a numbered
  2. list of items
  3. And we will see if it works.

The font size works, except not for headings.

Well, I am going to be using SilverStripe in a few months. I wonder if it will integrate with that.

Update: There was an issue where when I published this, it didn’t show up right away and said it “missed schedule” whatever that means.  I updated it and now shows up.

An interesting Artic: Unix's Revenge

The article is titled Unix’s Revenge and it was quite a good read.

Here is a quote:

Now we’ve entered a new decade of devices where Unix(-like) operating systems will, on a CPU basis, probably out-install Windows. Not only is iOS based on Unix, but Android and MeeGo and even Bada are based on Linux as are QNX and WebOS. Google, Apple, HP, RIM, Samsung and Nokia are all now betting heavily on Unix or Unix-like implementations. The success is so overwhelming that there are really only two hold-outs: Microsoft and the rapidly depreciating Symbian.

Read the full article here:
http://www.asymco.com/2010/09/29/unixs-revenge/

A brief history of my computer life…

Hello. I came across this post on the FreeBSD forums:  How you did you come FreeBSD world?

I started to respond but I felt my response was too long to put in a forum comment, so I am sticking it here on my blog.

A brief history of my computer life

My family had an Adam computer that ran on tape drives when I was young, boy was that Buck Rogers game and that Pong game awesome back then.  I did my math homework in a primitive text editor when I was in 4th grade (1986), even though it was harder than doing it with a pencil. Then at some point we got a 286 running DOS, which migrated to LeMenu, then to windows 3.11.  I remember hacking around Windows 3.1.1 just learning how the system worked.  Once moment, I would be gaming, the next, just looking at why the game installed the way it did, how the system was laid out.  At some point my family got a 386.

I remember getting online for the first time in 1994 with 14.4 modem. I remember windows 95. King’s Quest (1-6) were my favorite games.  At school I had programming and graphics course, all on Apple of some sort.

In 1995, I had a semester at the University of Utah which included one programming class. All their systems were unix based and we emailed using pine.

I didn’t touch computers much from 1996-1998 because I served a mission for my church in the Dominican Republic.  When I got back, Windows 98 was out and I earned enough to buy a computer. Technically it was the first computer that was “mine” because all the ones I had used before had belonged to my family or my school. StarCraft replaced King’s Quest as my favorite game.

In 1999 I took some MCSE courses. Around the same time, Microsoft outsourced their tech support for Windows 2000 to a company called Convergys.  This was in Orem, Utah. There was a guy there talking up Red Hat who gave me a Red Hat 6 CD. I told him to install it an get on the internet in under an hour.  It installed fine. But we never got it on the internet.  Turns out he was a newbie.  I played with Red Hat 6 for a week and never got Red Hat online. I was a Windows 2000 support guy anyway, right…I did get my NT 4.0 MCSE.

Well, Nortel Networks outsourced their tech support to the same place, and I jumped over there.  I guy named Joe introduced me to FreeBSD 4.6.

At some point, I convinced my brother to drop windows servers and use FreeBSD for his servers at his ISP, Psionyx.net (now FusionNetworks.com).

I then started www.bsdcertification.com, however, I was new to the BSD world and not really well-known and some other well-known members started www.bsdcertification.org a few months later, completely unaware of the effort I had put in.  At first I was irked and felt like they stole my project but I eventually got over it and turned my website over to them and now I am probably going to proxy exams at the upcoming UTOSC.

I got a job at LANDesk in 2004.  While it has an Agent for Linux/Unix it is pretty  much a windows tool.  I have really kept up my Windows knowledge and though I haven’t updated my MSCE, I probably have enough knowledge and experience with windows to be considered an expert. A year ago I became a developer with LANDesk and we do most everything in C# (though I get to touch legacy C++ code), so needless to say I use Windows 7 at work. I have really nice dev box running Windows 7 that is a VMWare host, and they give me a laptop with Windows 7 on it too.

So I’ve never really left Windows in the desktop world completely. I have a FreeBSD desktop and a FreeBSD server.  Actually, my work gives me a license for VMWare so I have dozens of virtual machines that I continue to use and test all kinds of platforms on, with FreeBSD being my open source platform of choice.  Twice I have gotten a FreeBSD server into production at LANDesk, once as a internal knowledge base, once as an SVN server, neither lasted.  I did become the subject matter expect for the LANDesk Linux agent and the LANDesk Linux-based appliance called the Management Gateway.

I am typing this on my work provided laptop that is running Windows 7.  I have a Remote Desktop session to a decently powerful computer that is also running Windows 7 and is a VMWare Workstation host (BSD is not supported as a VMWare host). As VMWare guests,  I have two FreeBSD VMs running currently and about a dozen freebsd VMs that I create for learning. Eventually, I delete them once I have learned what I created them to learn.

No I haven’t found a permanent FreeBSD project to call my home.  I keep dabbling here and there.  Mostly, I just document my learning, but eventually, I want to develop some BSD-related project.  It would also be awesome to have a job focused on FreeBSD.  However, I am way more than happy at LANDesk and I had an opportunity to leave for a Linux training company and I came close to doing so, but I just couldn’t leave a great company like LANDesk.  So the LANDesk and Windows world remains my work life, and FreeBSD remains one of my hobbies.

How to log all sql statements in Postgresql running on FreeBSD?

Enabling SQL Statement Logging in Postgresql

It is often nice to see what SQL statements an application will run.  Maybe there is a gui app to add a user and you want to script adding one thousand users and you want to make sure you know how users are add.

So in Microsoft SQL Server there is a SQL Profiler tool that will show you all the SQL statements.  However, when using Postgresql on FreeBSD, there is often nothing but the command line.

You can easily have all SQL statements logged to a file in Postgresql on FreeBSD.

Note: I already have a post on Installing and Using Postgresql on FreeBSD.

Logging all SQL statements

Here is how to do it:

Step 1 – Configure the postgresql.conf

  1. Open the postgresql.conf file.
    ee /usr/local/pgsql/data/postgresql.conf
    
  2. Find the log_statement value in the log. Uncomment it and set it to all.
    log_statement = 'all'                   # none, ddl, mod, all
    
  3. Close and save the postgresql.conf file.

Step 2 – Configure the syslog.conf

  1. Open the syslog.conf file.
    ee /etc/syslog.conf
    
  2. Add the following line to the end of the log.
    local0.*                                        /var/log/pgsql.log
    
  3. Close and save the syslog.conf file.

Step 3 – Create the log file

  1. Create the log file.
    touch /var/log/pgsql.log
    
  2. Make the file a little more secure.
    chmod 600 /var/log/pgsql.log
    

Step 4 – Restart Posgresql and Syslog services

  1. Restart the postgresql service.
    /usr/local/etc/rc.d/postgresql restart
    
  2. Or in FreeBSD 8.1 and later, you can use this syntax.

    service postgresql restart
    
  3. Restart the syslogd service.
    /etc/rc.d/syslogd restart
    

    Or in FreeBSD 8.1 and later, you can use this syntax.

    service syslogd restart
    

Ok, now you should be able to capture the sql statements.  Here is a log entry from my /var/log/pgsql.log.

Sep  9 22:10:26 FBSD81 postgres[18507]: [5-1] LOG:  statement: select * from "Member";

Logging the time it takes to execute the SQL statement

Ok, this assumes you have already done the steps above.

Step 1 – Configure the postgresql.conf

  1. Open the postgresql.conf file.
    ee /usr/local/pgsql/data/postgresql.conf
    
  2. Find the log_min_duration_statement value in the log. Uncomment this line and set it to zero.
    log_min_duration_statement = 0          # -1 is disabled, 0 logs all statements
                                            # and their durations, > 0 logs only
                                            # statements running at least this number
                                            # of milliseconds
    

    NOTE: It is interesting to note that you can have the log_statement value on or off.  So technically, enabling the log_min_duration_statement will also log all SQL statements if it is set to 0.

  3. Close and save the postgresql.conf file.

Step 2 – Restart Posgresql

  1. Restart the postgresql service.
    /usr/local/etc/rc.d/postgresql restart
    
  2. Or in FreeBSD 8.1 and later, you can use this syntax.

    service postgresql restart
    

Ok, now you should be able to capture the sql statements.  Here is a log entry from my /var/log/pgsql.log.

Sep  9 22:26:06 FBSD81 postgres[18759]: [4-1] LOG:  statement: select * from "Member";
Sep  9 22:26:06 FBSD81 postgres[18759]: [5-1] LOG:  duration: 0.957 ms

Logging SQL queries that take too long to execute

If the log_statement value is on.  All SQL

Step 1 – Configure the postgresql.conf

  1. Open the postgresql.conf file.
    ee /usr/local/pgsql/data/postgresql.conf
    
  2. Find the log_min_duration_statement value in the log. Uncomment this line and set it to a value in milisecond.  For example, to log any statement that takes longer than 3 seconds, use 3000.
    log_min_duration_statement = 3000     # -1 is disabled, 0 logs all statements
                                          # and their durations, > 0 logs only
                                          # statements running at least this number
                                          # of milliseconds
    
  3. Find the log_statement value in the log. Comment out the line or set the value to none (or both).
    #log_statement = 'none'                   # none, ddl, mod, all
    
  4. Close and save the postgresql.conf file.

Step 2 – Restart Posgresql

  1. Restart the postgresql service.
    /usr/local/etc/rc.d/postgresql restart
    
  2. Or in FreeBSD 8.1 and later, you can use this syntax.

    service postgresql restart
    

Ok, I don’t really have a SQL statement that will take 3 seconds, so I configured it for 10 milliseconds and I could see that statements that took less than 10 milliseconds were not logged while those that took more were logged.

IMPORTANT! Turn logging off when you are done

Don’t forget to turn this logging off when you are finished as this is a huge performance hit.  Leaving this on is not efficient and can result in slowness.

Drupal, Joomla, WordPress, SilverStripe, or other, which Content Management System (CMS) is best for a BSD user?

Choosing a Content Management System

Ok, so as today, August 26, 2010, my blog is hosted by WordPress.com.  It will be this way for some time.

However, I am probably going to eventually have my own server hosted somewhere. Probably with my brother’s company, Fusion Networks.

So I will probable build a FreeBSD server that will host my site.  At this point, I think I will stop using WordPress and use a different Content Management System.

Content Management Systems Lists

So I went into this having done reasearch before, so I knew what I was getting into.  There are plenty of different Content Management Systems and unfortunately there is no way I could find time to test them all.

Wikipedia had a great list of Content Management Systems.
http://en.wikipedia.org/wiki/List_of_content_management_systems

Ok, now that  you have seen the very large list of Content Management Systems, you realize that I have to narrow my list down without really testing them all.

Narrowing down the list

First, let me document what I would like and see if which fit into the list.  These are not in order of priority, and some are important and some are not.

I want it to

  1. use PHP
  2. have a large community
  3. use a BSD License
  4. use Postgresql (as it is BSD licensed and MySQL is not)
  5. import my existing WordPress blog
  6. have great feature sets
  7. have common plugins
  8. support multiple Blogs with one install
  9. manages website as well as blog
  10. manages multiple sites
  11. have a descent editor
  12. be well documenated

PHP-Based

They have their lists separated  into tables by programming language.  The PHP table has the most options and since I for sure want to use PHP, it is the only table I will focus on.  These tables even lists the license.

However, I did look at the other tables, just in case one was mostly PHP-based but didn’t show up in the PHP list.  For the full PHP list, go here:
http://en.wikipedia.org/wiki/List_of_content_management_systems#PHP_2

Large community

So the big three Content Management Systems seems to be these.  I don’t have any data to back this up.  I think this is just because these three seem to be more mentioned when doing Google searches.

  • Drupal
  • Joomla
  • WordPress

BSD Licensed

However, none of those are BSD Licensed, which I prefer. I am not opposed to GPL or LGPL, but I feel more comfortable with BSD licenses software.

The Content Management Systems that are PHP-based and use the BSD License are these:

Had one of the Big 3 been BSD licensed, my decision would have probably been easy.  However, obviously I am going to have to test some of the three BSD licensed Content Management Systems.

Supports Postgresql

Of the six Content Management Systems listed above, the following support Postgresql.

  • Drupal
  • Serendipity
  • SilverStripe

Can import my WordPress blog

It appears that they all can do this.

I am worried about links, however.  My blog entries often link to each other.  I question whether they do it perfectly.  For example, a link to one of my WordPress blogs might be this:

http://rhyous.com/2010/08/25/freebsd-now-has-the-service-command/

So the link has this format:

http://homepage/YYYY/MM/DD/name-of-blog-entry/

So if I go with something other than WordPress, then after importing my blogs, are all the links going to be broken?

Making the Decision

So here is the rating, after a very small overview of the different CMS web sites, and before verifying their marketing claims.

I am giving 0 to 3 points for each feature. (This is subject to change over time, should I want to come back after the decision and report on something).

Features Worpress Drupal Joomla Serendipity SilverStripe Pimcore
1. PHP-Based 3 3 3 3 3 3
2. Large community 3 3 3 1 1 1
3.BSD License 0 0 0 3 3 3
4. Postgresql Support 0 3 0 3 3 0
5. Imports WordPress 3 1 ? 1 1 ?
6. Great Feature set 3 3 3 1 3 ?
7. Has common plugins 3 3 3 3 2 ?
8. Multiple Blogs 3 3 3 3 2 ?
9. Manages Website as well as blog 3 3 3 0 3 ?
10. Multiple Sites 2 3 ? 0 3 ?
11. Editor 3 3 ? 2 3 ?
12. Documenation 3 3 ? 1 3 ?
Score: 29 31 ? 21 30 ?

Here is what I am going to do:

I am going to build a BSD, Apache, PHP, Postgresl virtual machine and test Drupal and Serendipity to see how the import goes.

Perhaps I will have a follow-up some time because:

  1. I have to test these different CMSes
  2. I am sure there are a dozen other items that should be scored 1-3 that I haven’t thought of.

Serendipity

I started out looking at Serendipity first.

Positives

http://rhyous.wordpress.com/wp-admin/post.php?post=2212&action=edit&message=1
There was a FreeBSD port.

The install was painless.

Negatives

Their web site didn’t seem very good, which is a big turn off for a company that is a CMS.

The links to their Forum on their web site and other pages were broken.  I did find that the forum does exist, so the links are just broken.

I tried to sign up for the Forum to report the broken links.  I registered, but was supposed to be sent a confirmation email, which I never received, even after re-requesting it, so I have never reported the broken links.  They are still broken a day later. Also, there appear to only be a handful of people on their forums at any given time. Both suggest they have a small community.

I couldn’t figure out how to design my home page. It seemed the blog was my home page.  I couldn’t figure out how to move my blog entries to a different page.

Result

If you want one blog and nothing else, this would work for you.

I need more. I stopped trying and have dropped Serendipity from the list.

SilverStripe

I looked at SilverStripe second and I way more pleased with its feature set.

Positives

Though I had some install problems, I found solutions on their forums.

There are a number of theme available for download.

The default web site had some common pages premade:

  • Home
  • About Us
  • Contact Us
  • Page not found

They had both Site Management and Blog management.

There are many extensions: modules, themes, widgets.

Modules include a Blog Modules and Sub-site module, so I could manage multiple sites and multiple blogs.

It is simple to download and install modules.

The user interface is simple and easy to use.

The documentation is sufficient.

Negatives

I had install/setup problems (that were resolved) by the Forum.  Supposedly they only occur with Postgresql.

Not a lot is included in the default install.

The community is smaller than I would like.

The documentation is only sufficient.

Conclusion

I really like the SilverStripe interface.

It had almost everything I am looking for.  It is BSD Licensed.  It supports Postgresql.

It is a Content Management System first, and has modules to add to it.  There a blog module, a multi-site module, which really interested me.

However, while it has a module to import a WordPress xml, I have yet to get it to work.  That is something I can live with, but I would prefer it to work.

Drupal

Positives

It has many features, and any feature it lacks is pretty much filled by an add-on or widget.

The documentations seems thorough.

The community looks to be large.

Negatives

I had to install a different version of wordpress to support multiple blogs.

It is GPL instead of BSD Licensed.

The admin site seemed rather overwhelming. There were almost too many options.

Conclusion

If this were BSD licensed, it would be my pick.  It seems great.

WordPress

Positives

It is popular and familiar.  The most common platform of the blogging world.

It has many features, and any feature it lacks is pretty much filled by an add-on or widget.

Migrating from my existing WordPress blog is flawless.

The community is huge.

The documentation is a plenty.

Negatives

It doesn’t support Postgresql.

It is GPL instead of BSD Licensed.

Joomla

I almost feel like apologizing to Joomla.  I had two BSD servers, one with FreeBSD, Apache, PHP, MySQL where I installed WordPress a year ago for testing.  I have another brand new server with FreeBSD, Apache, PHP, and Postgresql where I tested all the postgresql capable CRMs.  However, I installed Joomla to the wordpress server and it just didn’t work.  The page was blank.  I actually think there was a php error, not a Joomla error.

Unfortunately, Joomla doesn’t support postgresql, it isn’t BSD licensed.  I did research and it appears like it would score high with WordPress, Drupal, and Silverstripe, but I can’t really see how it would be any better than Drupal, or Silverstripe so I really had to cut it loose.  Lets be honest.  As a BSD users, it was beaten out by Drupal and Silverstripe for the same reason I am looking to replace WordPress.  It doesn’t support Postgresql.

Others

There are two other Content Management Systems that I feel are worth mentioning.

Django is also a CMS that is BSD licensed and supports Postgresql. However, it runs on Python, a language which I have occasionally touched but never really developed in.  If you know Python, this might be the choice for you.

Bricolage is also a CMS that is BSD licensed and supports Postgresql. However, it runs on Perl, which I have written a few things with, but not as much as PHP.  If you know Python, this might be the choice for you.

My Decision

I know, you all want to know which I chose to use.

Drumb roll please….

I have chosen…

But don’t expect my blog to move to Silverstripe tomorrow.  It move slowly with things like this.  It could take months or get delayed for a year.

Anyone who might choose a CMS differently would be completely happy with any of the others they evaluate and feel meets their needs.  I am not saying I chose the best.  I am saying I chose the best for my needs.  Hopefully, you know your needs and this will help you choose the best Content Management System for your needs.

The Utah Open Source Conference – October 7th, 8th, and 9th

Hey all,

I am going to be attending the Utah Open Source Conference and manning the BSD table for maybe part of or the majority of the time.

Here are some details:

There will probably be some BSD swag if you attend, courtesy of iXsystems and PC-BSD.

You can schedule a BSD Certification exam if you desire.

Hope all you computer geeks in Utah can attend.

If you aren’t into Open Source, then then this conference is especially for you. If you don’t know much about Open Source, then you are missing out.

If you are into Open Source, then you probably know about this conference already.

Installing and Using Postgresql on FreeBSD

Postrgesql is an excellent alternate to MySQL.

It is BSD Licensed instead of GPL, which is especially more attractive if you need to distribute the database software.  In fact, if you are reselling a product, and paying a license fee to MySQL you probably should save your company the money and move to Postgresql.  LANDesk, the company I work for, had just such an experience with our Management Gateway device.

Setting up FreeBSD

Ok, so I already have a post on this here:

How do I install FreeBSD?

Also, make sure to download ports.

What are the first commands I run after installing FreeBSD

Installing Postgresql on FreeBSD

As always, installing software on FreeBSD is simple using the ports system.

#
#
cd /usr/ports/databases/postgresql84-server
make WITH_OPTIMIZED_CFLAGS=true BATCH=yes install clean

Post-installation Setup

There a few post-installation steps.

Initialize the database

# /usr/local/etc/rc.d/postgresql initdb

Or starting with FreeBSD 8.1, you can now run this command:

# service postgresql initdb

Make any changes to the postgresql.conf

The postgresql.conf is located in /usr/local/pgsql/data.

Open the file and read through it and make any desired changes.

Common Changes

Here are two common changes.

Enabled remote connections

If the database is to be accessed by the network, then you should at least uncomment the setting #listen_addresses = 'localhost' and change it to listen_addresses = '*'.

Changing the default TCP Port

Uncomment the setting #port = 5432 and change the port number to the desired value.

Configure password authentication

  1. Change to the /usr/local/etc/pgsql/data directory.
  2. Edit the pg_hba.conf and change the default authentication method to something more secure, such as md5.
    # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD# "local" is for Unix domain socket connections only
    local   all         all                               md5
    # IPv4 local connections:
    host    all         all         127.0.0.1/32          md5
    # IPv6 local connections:
    host    all         all         ::1/128               md5
    

Configure the postgresql server service to start on reboot

Add the string postgresql_enable="YES" to /etc/rc.conf.

# echo ‘postgresql_enable=”YES”‘ >> /etc/rc.conf

Creating a Database

To create a database, su to pgsql and run createdb.

#
$
su pgsql
createdb MyDBName

Note: Similarly, use dropdb to drop a database.

Creating a User or Role

To create a user, su to pgsql and run createuser.

#
$
su pgsql
createuser -P

Enter name of role to add: MyUserOrRoleName
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) y

If you are not using password authentication, then you can exclude the -P.

Using psql client

A simple way to connect to postgresql is using the shell-based client, psql.

Connecting

To connect, use the following command.

$ psql MyDBName

MyDBName-#

You are now at the psql prompt.

Connecting as a different user

To connect, use the following command.

$ psql MyDBName MyUserOrRoleName

MyDBName-#

You are now at the psql prompt.

Changing a a User or Role Password

To change a password, use the following syntax.

MyDBName-# alter role pgsql with password ‘pw’;

Show Databases

To show database, simply type \l, (which is the lowercase letter L not the number 1) which is short hand in psql for this query:
SELECT datname FROM pg_database;

MyDBName-# \l

Show Tables

To show tables in the current database, simply type \d, which is short hand in psql for this query:
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';

MyDBName-# \d

Show Tables

To show columns of a table in the current database, simply type \d table, which is short hand in psql for this query:
SELECT column_name FROM information_schema.columns WHERE table_name ='table';

MyDBName-# \d MyTableName

Creating a Table

To create a table, use the following syntax:

MyDBName-# CREATE TABLE Users (
FirstName text,
LastName text,
DateOfBirth date
);

Inserting data into a Table

To insert data into a table, use the following syntax:

MyDBName-# CREATE TABLE Users (
UserId serial,
FirstName text,
LastName text,
DateOfBirth date
);

Ok, from here you should be able to start figuring everything out on your own.

Resources:
http://www.postgresql.org/docs/8.4/interactive/index.html


Copyright ® Rhyous.com – Linking to this page is allowed without permission and as many as ten lines of this page can be used along with this link. Any other use of this page is allowed only by permission of Rhyous.com.

FreeBSD now has the service command

So I was reading the FreeBSD 8.1 release notes today and noticed that FreeBSD added the services command.

Basically there are a lot of start up scripts in /etc/rc.d that are enabled in the /etc/rc.conf.  However, if you wanted to restart them, you always had to run /etc/rc.d/someservice start.  And if you didn’t remember the exact service syntax, you had to ls the dir.

Anyway, now with the services command, you can simple type this:

service someservice start

service someservice restart

I am familiar with this already as that is how Red Hat gets things done with their services.

If it was just /etc/rc.d scripts that this worked for, then this command doesn’t really save much typing. But it also works for installed services or services from ports. The start up scripts for services for ports are in /usr/local/etc/rc.d.

So after installing something you can use the simple service command to start it, instead of typing in the longer path.

Of course, service has other features, such as listing the start up scripts in the two directories: /etc/rc.d and /usr/local/etc/rc.d

Take a second to run man service to see all its options.

A windows annoyance: Copying folders with thousands of files

Ok, so have you ever started to copy a folder from the network and had it crash on you? And the folder of course has hundreds of subfolders and thousands of files, so you have to copy it again.

Why doesn’t windows handle this better. Why don’t I get a nice prompt that says: The copy failed…do you want to try again?  Yes / No

If i drag the folder over again, it seems to copy everything and give me annoying prompts for whether I want to overwrite the folder and the prompts can be endless.

I know I could avoid this by zipping the directory first, but really, zipping 1.5 GB of thousands of files takes even longer.

Sorry to drop a complaint today, but restarting massive folder transfers seems like an area where Microsoft has really not put any effort.

I will say that on my Windows 7 64 bit box, the number of annoying prompts to copy and replace were far less if I checked the box to not copy, so that is a positive.

Netcraft: Most Reliable Hosting Company Sites in July 2010

Netcraft has posted the most reliable hosting companies and of the top ten, five are using FreeBSD.
Most Reliable Hosting Company Sites in July 2010

I was informed about this by an email to the FreeBSD advocacy mailing list: advocacy@freebsd.org

Seems that this is something worth pointing out to companies who ask whether to use Windows, Linux, or BSD.

FreeBSD 8.1 Released today!

So I was browsing the FreeBSD Ftp yesterday and saw that FreeBSD 8.1-Release ISOs were available, and I almost jumped the gun and announced this yesterday.

http://www.freebsd.org/news/newsflash.html#event20100723:01

Duct Tape recommended to fix the iPhone4!

Yes, Duct Tape gets to add one more use to it already long bag of tricks.

Ok, this is seriously hilarious. Consumer Reports is very reputable. They don’t recommend the iPhone4 but recommend that if you have one, you fix it with Duct Tape.

Can there be anything funnier?

http://finance.yahoo.com/tech-ticker/article/519336/Consumer-Reports-Findings-Conflict-With-Apples-Statement-On-iPhone-4

How to determine if an MSI patch (.msp file) has been applied using C++?

Ok, so I need to determine if a patch has been applied to an MSI. Lets start with Enumerating the installed products and enumerating all the patches applied for each installed product.

I guess the title should be “How to enumerate installed MSI products and their applied MSP patches.”

I have to do it in C++, which is a drag because it looked like three lines of code in C#, but hey, maybe it isn’t so hard with C++ using .NET as well.

I researched on MSDN, of course.  It looks like I need to use this function: MsiGetPatchInfoEx.  However, I need to know the MSI GUID in order to use that function, so I might as well learn to use the MsiEnumProducts, MsiGetProductInfo, MsiEnumPatches to match the Product to an MSI Guid and that to a patch.

Creating the Project

  1. I created a new Project in Visual Studio to test this out. The project type I used was under C++ and is called Win32 Console application.
  2. I didn’t make any changes to the default code provided: targetver.h, stafx.h, stafx.cpp.
  3. Make sure you have the Platform SDK installed for the next step.
  4. I went to the project properties and went to Linker | Inpuut and added to Additional Dependencies the following line:
    "$(WindowsSdkDir)Lib\msi.lib"
    
  5. I wrote my code.

Learning the Code
So here is what the code I wrote in this little learning project will do:

  1. Create a list or vector to store each MSIProduct.
  2. Loop through each installed MSIs using the MsiEnumProducts function and for each installed MSI:
  3. Get MSI information using MSIProductInfo.
  4. Create an MSIProduct object using the information from MSIProductInfo and add the MSIProduct to the list or vector.
  5. Write to standard output the MSI count (as Id), the MSI name, and the MSI Guid.
  6. Create a list or vector to store each MSIPatch.
  7. Check if any patches or MSPs are applied to the MSI and for each patch:
  8. Get MSP information using MSIPatchInfoEx.
  9. Create an MSIPatch object using the information from MSIPatchInfoEx and add the MSIPatch to this list or vector.
  10. Write to standard output the MSP Guid.

Here is my code:

Run.cpp
This file does all the work and has the tmain function. It creates a list or vector of MSIProduct objects and then uses MsiEnumProducts and MsiGetProductInfo to create and add each MSIProduct to the vector.  It also loops through each of the MSIProduct‘s and find any installed patches.  It adds each patch found to the MSIProduct‘s _Patches vector.

// Run.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "windows.h"
#include "Msi.h"
#include "MSIProduct.h" // Includes MSIBase.h and MSIPatch.h as well
#include <iostream>
#include <vector>

using namespace std;

#define MYSIZE 512

int _tmain(int argc, _TCHAR* argv[])
{
	// Step 1. Create a list or vector to store each MSIProduct.
	vector<MSIProduct> *products = new vector<MSIProduct>();

	// Step 2. Loop through each installed MSIs using the MsiEnumProducts
	//            function and for each installed MSI:
	int i = 0;
	bool foundMoreApps = true;
	while (foundMoreApps)
	{
		DWORD size = MYSIZE;
		LPTSTR tmpGuid = new TCHAR[MYSIZE];
		LPTSTR tmpName = new TCHAR[MYSIZE];

		UINT ret1 = MsiEnumProducts(i, tmpGuid);
		if (ret1 > 0)
		{
			foundMoreApps = false;
			continue;
		}

		// Step 3. Get MSI information using MSIProductInfo.
		UINT ret2 = MsiGetProductInfo(tmpGuid, INSTALLPROPERTY_PRODUCTNAME, tmpName, &size);
		if (ret2 > 0)
		{
			// Todo: Handle failure
		}

		// Step 4. Create an MSIProduct object using the information from MSIProductInfo
		//            and add the MSIProduct to the list or vector.
		products->push_back(MSIProduct());
		products->at(i).SetName(tmpName);
		products->at(i).SetGuid(tmpGuid);

		// Step 5. Write to standard output the MSI count (as Id), the MSI name, and the MSI Guid.
		cout << endl;
		cout << "Id: " << i << endl;
		wcout << "Product: " << tmpName << endl;
		wcout << "Guid: " << tmpGuid << endl;
		cout << "Patches: ";

		// Step 6. Create a list or vector to store each MSIPatch.
		vector<MSIPatch> *patches = new vector<MSIPatch>();
		products->at(i).SetPatches(patches);

		// Step 7. Check if any patches or MSPs are applied to the MSI and for each patch:
		int j = 0;
		bool foundMorePatches = true;
		while (foundMorePatches)
		{
			DWORD size = MYSIZE;
			LPTSTR tmpPatchGuid = new TCHAR[MYSIZE];
			LPTSTR tmpPatchState = new TCHAR[MYSIZE];
			LPTSTR tmpPatchTransforms = new TCHAR[MYSIZE];

			UINT retPatch1 = MsiEnumPatches(tmpGuid, j, tmpPatchGuid, tmpPatchTransforms, &size);
			if (retPatch1 > 0)
			{
				cout << "(" << retPatch1 << ") :" << endl;
				foundMorePatches = false;
				continue;
			}

			// These values correspond to the constants the dwFilter parameter
			// of MsiEnumPatchesEx uses.

			// Step 8. Get MSP information using MSIPatchInfoEx.
			UINT retPatch2 = MsiGetPatchInfoEx(tmpPatchGuid, tmpGuid, NULL, MSIINSTALLCONTEXT_MACHINE, INSTALLPROPERTY_PATCHSTATE, tmpPatchState, &size);
			// Returns "1" if this patch is currently applied to the product.
			// Returns "2" if this patch is superseded by another patch.
			// Returns "4" if this patch is obsolete.
			if (retPatch2 > 0)
			{
				// Todo: Handle failure
			}

			// Step 9. Create an MSIPatch object using the information from MSIPatchInfoEx
			//            and add the MSIPatch to this list or vector.
			patches->push_back(MSIPatch());
			patches->at(j).SetPatchState(tmpPatchState);
			patches->at(j).SetGuid(tmpPatchGuid);
			patches->at(j).SetTransforms(tmpPatchTransforms);

			// Step 9. Write to standard output the MSP Guid.
			wcout << "\t" << "Patch Guid: " << tmpPatchGuid << endl;

			j++;
		}

		i++;
	}
}
&#91;/sourcecode&#93;

I did create some simple supporting classes for this:

<strong>MSIBase.h</strong>

[sourcecode language="cpp"]
#pragma once
#include "windows.h"

class MSIBase
{
  public:

	// Constructor
	MSIBase(void);

	// Destructor
	virtual ~MSIBase(void);

	// Accessor functions
	LPTSTR GetName();
	void SetName(LPTSTR inName);

	LPTSTR GetGuid();
	void SetGuid(LPTSTR inGuid);

  protected:
	LPTSTR _Guid;
	LPTSTR _Name;
};

MSIBase.cpp

#include "StdAfx.h"
#include "MSIBase.h"

MSIBase::MSIBase(void)
{
}

MSIBase::~MSIBase(void)
{
}

// Accessor functions
LPTSTR  MSIBase::GetName()
{
	return _Name;
}

void MSIBase::SetName(LPTSTR inName)
{
	_Name = inName;
}

LPTSTR  MSIBase::GetGuid()
{
	return _Guid;
}

void MSIBase::SetGuid(LPTSTR inGuid)
{
	_Guid = inGuid;
}

MSIProduct.h

#include "MSIBase.h"
#include "MSIPatch.h"
#include <vector>

#pragma once
class MSIProduct : public MSIBase
{
public:
	MSIProduct(void);
	~MSIProduct(void);

	std::vector<MSIPatch> GetPatches();
	void SetPatches(std::vector<MSIPatch> * inPatches);
	void AddPatch(MSIPatch inPatch);

protected:
	std::vector<MSIPatch> * _Patches;
};

MSIProduct.cpp

#include "StdAfx.h"
#include "MSIProduct.h"

MSIProduct::MSIProduct(void)
{
}

MSIProduct::~MSIProduct(void)
{
	delete _Patches;
}

std::vector<MSIPatch> MSIProduct::GetPatches()
{
	return * _Patches;
}

void MSIProduct::SetPatches(std::vector<MSIPatch> * inPatches)
{
	_Patches = inPatches;
}

void MSIProduct::AddPatch(MSIPatch inPatch)
{
	_Patches->push_back(inPatch);
}

MSIPatch.h

#pragma once
#include "MSIBase.h"

class MSIPatch : public MSIBase
{
public:
	MSIPatch(void);
	~MSIPatch(void);

	LPTSTR GetTransforms();
	void SetTransforms(LPTSTR inTransforms);
	int GetPatchState();
	void SetPatchState(int inPatchState);
	void SetPatchState(LPTSTR inPatchState);

protected:
	LPTSTR _Transforms;
	int _PatchState;
};

MSIPatch.cpp

#include "StdAfx.h"
#include "MSIPatch.h"

MSIPatch::MSIPatch(void)
{
}

MSIPatch::~MSIPatch(void)
{
}

LPTSTR  MSIPatch::GetTransforms()
{
	return _Transforms;
}

void MSIPatch::SetTransforms(LPTSTR inTransforms)
{
	_Transforms = inTransforms;
}

int  MSIPatch::GetPatchState()
{
	return _PatchState;
}

void MSIPatch::SetPatchState(int inPatchState)
{
	_PatchState = inPatchState;

}

void MSIPatch::SetPatchState(LPTSTR inPatchState)
{
	_PatchState = _wtoi(inPatchState);
}

Sorry, I am not explaining in more detail, my time is limited.

Note: I found one problem where an application has a ™ in the name. (Skype™ 4.2) and the output doesn’t work well after that.


Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.