$! isn't reliable after a system(). The 512 means that the called program returned 512>>8, or 2. So look at the called program's manual page or other documentation, and find out what would make it exit with an error 2.
Comment on Re: Re: Re: Illegal seek error for system()