Executing Spice commands written in file

simulationspice

I successfully executed ngspice commands via the command line.
When I wrote those commands to the .net file, and run that file via ngspice, they didn't work.

The following is my netlist file:

* gnetlist -g spice-sdb ./RC_filter.sch
* Spice file generated by gnetlist                      *
* spice-sdb version 4.28.2007 by SDB --                 *
R1 2 1 1MEG  
V1 2 0 DC 5V
C1 1 0 1uF  

* Set Initial conditions: Voltage on Capacitor C1 is being set to zero
.IC V(1)=0

.end

When that file is loaded to ngspice, and then I run the following commands:

tran 10m 5s
plot V(1)

They work perfectly.

But when those commands are written in the .net file, right before the .end line, they don't work when ngspice reads the file:

* ... Rest of file

.tran 10m 5s
.plot V(1)

.end

How can I make these commands to work?

Thank you.

Best Answer

Have a look at the description of .control / .endc in the ngspice manual.

You will have to write something like:

.control
tran ...
plot v(1)
.endc