I don't have SQLCL, but this (redirection to file) should (at least, I hope so) work at operating system command prompt.
myfile1.sql:
select * from dept;
myfile2.sql:
select empno, ename, job, sal
from emp
where deptno = 10;
mypath1.sql:
@"myfile1"
@"myfile2"
exit;
mybat.bat:
sqlplus scott/tiger@orcl@mypath1.sql > mylog.txt
-----------
this redirects output into mylog.txt file
Running the mybat.bat
at the command prompt:
C:\>mybat
C:\>sqlplus scott/tiger@orcl@mypath1.sql 1>mylog.txt
There's no output to screen; everything is contained in mylog.txt
file so - let's check it:
C:\>type mylog.txt
SQL*Plus: Release 18.0.0.0.0 - Production on Čet Sij 19 08:18:58 2023
Version 18.5.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Active code page: 1250
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
EMPNO ENAME JOB SAL
---------- ---------- --------- ----------
7782 CLARK MANAGER 2450
7839 KING PRESIDENT 5000
7934 MILLER CLERK 1300
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
C:\>