Easy option : call sqlplus with NOLOG , this way :

C:\>sqlplus /NOLOG @test_connection.sql

and in your test_connection.sql script, you use something like :

whenever sqlerror exit
connect user/pass@alias
exit


Regards,

Chiappa