Using SMS and smsq to process incoming SMS messages

Hello,

When SMS receives a text from a user, I would like to intercept this and write it to a database. How do I set PHP to access the smsq --process command?

Is this passed through STDIN?

Thanks,

John