portability updates.  replaced system() calls with open()