There are numerous tools available for Linux that allow the user to interact with Serial devices (usually known as Terminals or Serial Terminals), such as mincom or screen to name two, which are generally great at what they do, but experience shows they are not so good for scripting -