I begin all my scripts with %!PS, and I am wondering what I can do to make the scripts system executable. So far i have been runing everything from the ghostscript terminal. I tried making the files executeable, but it results in errors amounting to the script being run line by line, and being missinterpreted.
Heres a simple source:
%!PS
/Times findfont 72 scalefont setfont
306 396 translate % move center to here
4{
2 2 moveto
90 rotate
(H@x0rz) true charpath stroke
}repeat
showpage
and here are the errors that follow when trying to run it.
$ ./rotate.ps
./rotate.ps: line 1: fg: no job control
./rotate.ps: line 2: /Times: No such file or directory
./rotate.ps: line 3: 306: command not found
./rotate.ps: line 5: 4{: command not found
./rotate.ps: line 6: 2: command not found
./rotate.ps: line 7: 90: command not found
./rotate.ps: line 8: syntax error near unexpected token `true'
./rotate.ps: line 8: ` (H@x0rz) true charpath stroke'
how can I make my postscript files system executable. using Ubuntu Mate 18.04 or later.
EDIT trying to use binfmt-misc::
OK so I am looking at setting up binfmt-misc to execute the postcript, but I am not sure how to set it up. In
#/proc/sys/fs/binfmt_misc$ ls
register status
the status file says enabled, and the register file is blank.
on the binfmt-misc wiki page I see some examples, but I also see a reference to a "TYPE CODE" and i do not know what that is for postscript.
I tried adding GS:M:MZ::/home/user/bin/gs to register, via vim and echo but I got read and write errors even as root, and now I get permission denied when I try to edit the register file.
root@xy:/proc/sys/fs/binfmt_misc# echo 'GS:M:MZ::/home/user/bin/gs' > register
-bash: echo: write error: Invalid argument
Admitadly, I have no clue what I am doing.
I also tried putting a shebang with the ghostscript path at the first line of my script, and that comes back with ghostscript having an unrecoverable error, it loads a window that immediately closes. Im not sure what to do.
the websites I have been reading are: https://elixir.bootlin.com/linux/v4.6/source/Documentation/binfmt_misc.txt https://en.wikipedia.org/wiki/Binfmt_misc