in reply to could not open c

I do not know if this change your error, but system return 0 on success. You test for > 0 somewhere but -1 is also a valid return value. See: system.
Boris