connect to sqlplus in a script

Hi,
I want to write a script, in which I will connect to sqlplus and do a quary and then exit
sqlplus user/pwd@database
select count(*) from table
exit.
and write the result in a log file.

How to write it ?
Many thanks before.

This is answer
check the above link same question was answered there.
please use search on forum you will find plenty of same thread.