# Is it possible to pass netlist via command line to ngspice instead of using input file?

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.

• Isn't there a -p pipe mode for the program? Or do you mean something different? – jonk Jun 13 '19 at 5:30
• can you please provide an example using the -p pipe mode? – simo Jun 13 '19 at 5:32
• I don't use ngspice (or Kicad, which uses ngspice.) But I've heard about the pipe mode perhaps a decade ago. I'm just assuming it's still there. But I've never used it. (There was a problem in ngspice many years ago where outputting anything to a file would cause it to go into file block mode on the input and this made a mess of things. That's where I had heard about the feature. But it was fixed a long time ago, I think. I'm going on vague recollections. But those recollections do suggest to me that you should look into it. There's a manual, I'm sure.) – jonk Jun 13 '19 at 5:36
• Possible duplicate of Running ngspice from command line on a Linux and Windows machine. – Huisman Jun 13 '19 at 7:08
• If I do understand your question, you would like something like: ngspice "voltage divider netlist V1 in 0 1 R1 in out 1k R2 out 0 2k .end" ... How do you get this string in the first place? – Huisman Jun 13 '19 at 12:27

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.
• I don't want to use any GUI, I just want to be able to pass netlist to ngspice  without using a file but I have no idea about the pipe mode, can you please share an example of passing netlist using pipe mode? – simo Jul 10 '19 at 8:35