Electronic – Is it possible to pass netlist via command line to ngspice instead of using input file

ngspice

Is there a way to use ngspice command line without providing a circuit file? ex: passing the circuit as a string within the command line ?

EDIT

Currently the only way I could use ngspice in command line is by providing an input file.. I could not find an example of using pipe mode though to pass netlist directly via command line without have to use a file to read from.

Best Answer

As commented before, the Window GUI version of ngspice will not work with pipes due to a Windows specific I/O handling.
Maybe you could try finding a workaround.

I think you should have the GUI write the netlist to a file called e.g. "circuit.cir" and have the code of the GUI execute ngspice circuit.cir.

Another option having the GUI making a string based on the netlist and using a batch file which parses the netlist string, writes it to (e.g.) "circuit.cir" and lastly, executes ngspice circuit.cir.
Make sure you seperate each line of the netlist with a unique character (e.g. ¶ or ­§ or whatever) when making one big string of it.