Run Oracle SQL script and exit from sqlplus.exe via command prompt

Another way is to use this command in the batch file:

echo exit | sqlplus user/pass@connect @scriptname

I found this to be the best solution and it works in a terminal or within a script:

echo @scriptname | sqlplus username/password@connect

Realizing now that your problem may be with the sql file itself, realize that sqlplus needs to be told to exit. The way I do this is:

select * from dual;

quit;
/

(The slash is important. It tells sqlplus to execute the statemet(s) above it.)