Search code examples
cghostscriptpostscript

What does this ghostscript error means undefinedfilename in


I want to run the Ghostscript command for drawing lines from a C program. I am using execlp() system call to run the command. When I am trying to run the command for line drawing from terminal/C, I am getting the same error like this:

GPL Ghostscript 9.55.0 (2021-09-27)

Copyright (C) 2021 Artifex Software, Inc.  All rights reserved.

This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:

see the file COPYING for details.

Error: /undefinedfilename in (100)

Operand stack:



Execution stack:

   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push

Dictionary stack:

   --dict:761/1123(ro)(G)--   --dict:0/20(G)--   --dict:75/200(L)--

Current allocation mode is local

Last OS error: No such file or directory

GPL Ghostscript 9.55.0: Unrecoverable error, exit code 1

The command I am running for drawing is this postscript command(drawing a line)

gs 100 100 moveto 300 300 lineto closepath stroke

Solution

  • You need to add the flag "-c". The gs command will then be

    gs -c 100 100 moveto 300 300 lineto closepath stroke