* Quoting in mptopdf.pl @ 2001-04-22 21:23 Hartmut Henkel 2001-04-23 16:20 ` Hans Hagen 0 siblings, 1 reply; 8+ messages in thread From: Hartmut Henkel @ 2001-04-22 21:23 UTC (permalink / raw) Hi, I use mptopdf.pl for conversion of MetaPost output into PDF under debian 2.2 r2 Linux. I renamed mptopdf.pl into mptopdf, put it into directory /usr/local/bin, and made it executable (chmod ugo+rx). It works nicely, but for this I had to change the quoting in the line with the pdftex call into: { system ("pdftex \\\&mptopdf \\\\relax $file") ; Why are these additional backslashes for quoting necessary? Thank you very much for your help. Best Regards Hartmut ------------------------------------------------------------------------ Dr.-Ing. Hartmut Henkel In den Auwiesen 6 D-68723 Oftersheim Germany E-Mail: hartmut_henkel@gmx.de ------------------------------------------------------------------------ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quoting in mptopdf.pl 2001-04-22 21:23 Quoting in mptopdf.pl Hartmut Henkel @ 2001-04-23 16:20 ` Hans Hagen 2001-04-23 21:47 ` Hartmut Henkel 2001-04-24 7:02 ` James H. Cloos Jr. 0 siblings, 2 replies; 8+ messages in thread From: Hans Hagen @ 2001-04-23 16:20 UTC (permalink / raw) Cc: ConTeXt mailing list At 11:23 PM 4/22/01 +0200, Hartmut Henkel wrote: >Hi, > >I use mptopdf.pl for conversion of MetaPost output into PDF under debian >2.2 r2 Linux. I renamed mptopdf.pl into mptopdf, put it into directory >/usr/local/bin, and made it executable (chmod ugo+rx). > >It works nicely, but for this I had to change the quoting in the line >with the pdftex call into: > > { system ("pdftex \\\&mptopdf \\\\relax $file") ; > >Why are these additional backslashes for quoting necessary? Do you mean that is does not otherwise run on linux? There are unix experts on this list who should know why, Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quoting in mptopdf.pl 2001-04-23 16:20 ` Hans Hagen @ 2001-04-23 21:47 ` Hartmut Henkel 2001-04-24 7:22 ` Hans Hagen 2001-04-24 7:24 ` S2P development 2001-04-24 7:02 ` James H. Cloos Jr. 1 sibling, 2 replies; 8+ messages in thread From: Hartmut Henkel @ 2001-04-23 21:47 UTC (permalink / raw) Cc: ConTeXt mailing list On Mon, 23 Apr 2001, Hans Hagen wrote: > At 11:23 PM 4/22/01 +0200, Hartmut Henkel wrote: > >Hi, > > > >I use mptopdf.pl for conversion of MetaPost output into PDF under debian > >2.2 r2 Linux. I renamed mptopdf.pl into mptopdf, put it into directory > >/usr/local/bin, and made it executable (chmod ugo+rx). > > > >It works nicely, but for this I had to change the quoting in the line > >with the pdftex call into: > > > > { system ("pdftex \\\&mptopdf \\\\relax $file") ; > > > >Why are these additional backslashes for quoting necessary? > > Do you mean that is does not otherwise run on linux? There are unix experts > on this list who should know why, Yes, it does not otherwise run. When I simply rename mptopdf.pl into mptopdf and make it executable, I get e. g.: # $ mptopdf smithchart.1 # This is pdfTeX, Version 3.14159-13d (Web2C 7.3.1) # ** # ! End of file on the terminal... why? # # MPtoPDF 1.0: no filename matches relax.* # # MPtoPDF 1.0: smithchart.1 is converted to smithchart-1.pdf and _no_ smithchart-1.pdf is generated. Only after the above change, adding backslashes, it works correctly. Greetings Hartmut ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quoting in mptopdf.pl 2001-04-23 21:47 ` Hartmut Henkel @ 2001-04-24 7:22 ` Hans Hagen 2001-04-24 19:45 ` Hartmut Henkel 2001-04-24 7:24 ` S2P development 1 sibling, 1 reply; 8+ messages in thread From: Hans Hagen @ 2001-04-24 7:22 UTC (permalink / raw) Cc: ConTeXt mailing list At 11:47 PM 4/23/01 +0200, Hartmut Henkel wrote: >Only after the above change, adding backslashes, it works correctly. Can you check i fthis works ok? I now test for win/dos which fails with //// ; i now use -fmt instead of the & because on newer wins the & is also a problem, Hans eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q' if 0; #D \module #D [ file=mptopdf.pl, #D version=2000.05.29, #D title=converting MP to PDF, #D subtitle=\MPTOPDF, #D author=Hans Hagen, #D date=\currentdate, #D url=www.pragma-ade.nl, #D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] #C #C This module is part of the \CONTEXT\ macro||package and is #C therefore copyrighted by \PRAGMA. See licen-en.pdf for #C details. # use File::Copy ; # not in every perl use Config ; $program = "MPtoPDF 1.0" ; $pattern = $ARGV[0] ; $done = 0 ; $report = '' ; my $dosish = ($Config{'osname'} =~ /dos|win/i) ; sub CopyFile # agressive copy, works for open files like in gs { my ($From,$To) = @_ ; return unless open(INP,"<$From") ; binmode INP ; return unless open(OUT,">$To") ; binmode OUT ; while (<INP>) { print OUT $_ } close (INP) ; close (OUT) } if (($pattern eq '')||($pattern =~ /^\-+(h|help)$/io)) { print "\n$program: provide MP output file (or pattern)\n" ; exit } elsif ($pattern =~ /\.mp$/io) { $error = system ("texexec --mptex $pattern") ; if ($error) { print "\n$program: error while processing mp file\n" ; exit } else { $pattern =~ s/\.mp$//io ; @files = glob "$pattern.*" } } elsif (-e $pattern) { @files = ($pattern) } elsif ($pattern =~ /.\../o) { @files = glob "$pattern" } else { $pattern .= '.*' ; @files = glob "$pattern" } foreach $file (@files) { $_ = $file ; if (s/\.(\d+)$// && -e $file) { if ($dosish) { system ("pdftex -progname=pdftex -fmt=mptopdf \\relax $file") } else { system ("pdftex -progname=pdftex -fmt=mptopdf \\\\relax $file") } rename ("$_.pdf", "$_-$1.pdf") ; if (-e "$_.pdf") { CopyFile ("$_.pdf", "$_-$1.pdf") } if ($done) { $report .= " +" } $report .= " $_-$1.pdf" ; ++$done } } if ($done) { print "\n$program: $pattern is converted to$report\n" } else { print "\n$program: no filename matches $pattern\n" } ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quoting in mptopdf.pl 2001-04-24 7:22 ` Hans Hagen @ 2001-04-24 19:45 ` Hartmut Henkel 0 siblings, 0 replies; 8+ messages in thread From: Hartmut Henkel @ 2001-04-24 19:45 UTC (permalink / raw) Cc: ConTeXt mailing list On Tue, 24 Apr 2001, Hans Hagen wrote: > At 11:47 PM 4/23/01 +0200, Hartmut Henkel wrote: > > >Only after the above change, adding backslashes, it works correctly. > > Can you check i fthis works ok? I now test for win/dos which fails with > //// ; i now use -fmt instead of the & because on newer wins the & is also > a problem, > > Hans > > > eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S > $0 $argv:q' > if 0; > > #D \module > #D [ file=mptopdf.pl, > #D version=2000.05.29, > #D title=converting MP to PDF, > #D subtitle=\MPTOPDF, > #D author=Hans Hagen, > #D date=\currentdate, > #D url=www.pragma-ade.nl, > #D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] > #C > #C This module is part of the \CONTEXT\ macro||package and is > #C therefore copyrighted by \PRAGMA. See licen-en.pdf for > #C details. > > # use File::Copy ; # not in every perl > use Config ; > > $program = "MPtoPDF 1.0" ; > $pattern = $ARGV[0] ; > $done = 0 ; > $report = '' ; > > my $dosish = ($Config{'osname'} =~ /dos|win/i) ; > > sub CopyFile # agressive copy, works for open files like in gs > { my ($From,$To) = @_ ; > return unless open(INP,"<$From") ; binmode INP ; > return unless open(OUT,">$To") ; binmode OUT ; > while (<INP>) { print OUT $_ } > close (INP) ; > close (OUT) } > > if (($pattern eq '')||($pattern =~ /^\-+(h|help)$/io)) > { print "\n$program: provide MP output file (or pattern)\n" ; > exit } > elsif ($pattern =~ /\.mp$/io) > { $error = system ("texexec --mptex $pattern") ; > if ($error) > { print "\n$program: error while processing mp file\n" ; exit } > else > { $pattern =~ s/\.mp$//io ; > @files = glob "$pattern.*" } } > elsif (-e $pattern) > { @files = ($pattern) } > elsif ($pattern =~ /.\../o) > { @files = glob "$pattern" } > else > { $pattern .= '.*' ; > @files = glob "$pattern" } > > foreach $file (@files) > { $_ = $file ; > if (s/\.(\d+)$// && -e $file) > { if ($dosish) > { system ("pdftex -progname=pdftex -fmt=mptopdf \\relax $file") } > else > { system ("pdftex -progname=pdftex -fmt=mptopdf \\\\relax $file") } > rename ("$_.pdf", "$_-$1.pdf") ; > if (-e "$_.pdf") { CopyFile ("$_.pdf", "$_-$1.pdf") } > if ($done) { $report .= " +" } > $report .= " $_-$1.pdf" ; > ++$done } } > > if ($done) > { print "\n$program: $pattern is converted to$report\n" } > else > { print "\n$program: no filename matches $pattern\n" } > > ------------------------------------------------------------------------- > Hans Hagen | PRAGMA ADE | pragma@wxs.nl > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com > ------------------------------------------------------------------------- Yes, that works now fine under Linux. --- after I have removed also your signature lines :-) Thank you very much for help. Best Regards Hartmut ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quoting in mptopdf.pl 2001-04-23 21:47 ` Hartmut Henkel 2001-04-24 7:22 ` Hans Hagen @ 2001-04-24 7:24 ` S2P development 2001-04-24 8:03 ` Zeljko Vrba 1 sibling, 1 reply; 8+ messages in thread From: S2P development @ 2001-04-24 7:24 UTC (permalink / raw) Hartmut Henkel wrote: > > On Mon, 23 Apr 2001, Hans Hagen wrote: > > > >Why are these additional backslashes for quoting necessary? > > > > Do you mean that is does not otherwise run on linux? There are unix experts > > on this list who should know why, > > Yes, it does not otherwise run. When I simply rename mptopdf.pl into Other (previous?) versions just called texexec, without problems. Since adding backslashes esp. for linux is not a particularly nice solution, perhaps someone on Dos or Win could try if this works: system ("pdftex '&mptopdf \relax $file'") That would remove the need for extra backslashes. I'm not sure if command.com ignores these single quotes, though. Greetings, Taco ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quoting in mptopdf.pl 2001-04-24 7:24 ` S2P development @ 2001-04-24 8:03 ` Zeljko Vrba 0 siblings, 0 replies; 8+ messages in thread From: Zeljko Vrba @ 2001-04-24 8:03 UTC (permalink / raw) Cc: ntg-context On Tue, Apr 24, 2001 at 09:24:54AM +0200, S2P development wrote: > Since adding backslashes esp. for linux is not a particularly nice > solution, perhaps someone on Dos or Win could try if this works: > > system ("pdftex '&mptopdf \relax $file'") > This definetly won't work on either DOS/Win or Linux because perl will interpret \ inside double quotes and ignore single quotes. That way you will execute literally: pdftex '&mptopdf <CARRIAGE-RETURN>elax <FILENAME>' ^^^ this is from \r Whatever command.com does with ' quotes is beyond me. The CORRECT ways are: system '/usr/bin/pdftex &mptopdf \relax ' . $file; - or - system('/usr/bin/pdftex', '&mptopdf', '\relax', '$file) Previous poster made a mistake with '\\relax'; nothing needs esacping inside single quotes. I write full paths for security reasons (that way program locations don't get looked up from PATH shell variable). ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Quoting in mptopdf.pl 2001-04-23 16:20 ` Hans Hagen 2001-04-23 21:47 ` Hartmut Henkel @ 2001-04-24 7:02 ` James H. Cloos Jr. 1 sibling, 0 replies; 8+ messages in thread From: James H. Cloos Jr. @ 2001-04-24 7:02 UTC (permalink / raw) Cc: Hartmut Henkel, ConTeXt mailing list >>>>> "Hans" == Hans Hagen <pragma@wxs.nl> writes: >> { system ("pdftex \\\&mptopdf \\\\relax $file") ; >> Why are these additional backslashes for quoting necessary? Hans> Do you mean that is does not otherwise run on linux? There are Hans> unix experts on this list who should know why, When you pass a string with spaces to perl's system(), it passes the string to the shell. So you need to pass the \s through the shell, thus the need for double escaping. It would probably be better to pass a list of strings to system(), one per arg: system('pdftex', '&mptopdf', '\\relax', $file) ; ought to do it, if I'm correctly reading what you want to args to pdftex(1) to be. -JimC -- James H. Cloos, Jr. <http://jhcloos.com/public_key> 1024D/ED7DAEA6 <cloos@jhcloos.com> E9E9 F828 61A4 6EA9 0F2B 63E7 997A 9F17 ED7D AEA6 ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2001-04-24 19:45 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2001-04-22 21:23 Quoting in mptopdf.pl Hartmut Henkel 2001-04-23 16:20 ` Hans Hagen 2001-04-23 21:47 ` Hartmut Henkel 2001-04-24 7:22 ` Hans Hagen 2001-04-24 19:45 ` Hartmut Henkel 2001-04-24 7:24 ` S2P development 2001-04-24 8:03 ` Zeljko Vrba 2001-04-24 7:02 ` James H. Cloos Jr.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).