How to programmatically put offline/online a user

I would like to create a script to be called from external programs that force offline/online an openfire chat user.

Which are the correct steps to follow to put a user offline?

Thanks in advance and greetings

c.