harryC has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I can print rtf files from the command line on the windows default printer with following command:
c:\program files\openoffice\soffice\swriter.exe -p test.rtf
How can i ivoke this command in the background from a perl script
thanks for you response

Considered by gellyfish: duplicate of Re^2: Moving from MS Office OLE code to Openoffice for printing RTF documents
Unconsidered by GrandFather: keep (and edit) votes prevented reaping; Keep: 6, Edit: 1, Reap: 6

  • Comment on Printing rtf-files with openoffice windows xp

Replies are listed 'Best First'.
Re: Printing rtf-files with openoffice windows xp
by ikegami (Patriarch) on Jul 31, 2006 at 20:02 UTC
    system launches a program. If the first argument is 1, the program is launched in the background (Windows only). Passing the parameters as seperate strings (as opposed to passing a single string to system) prevents injection attacks/bugs.
    my $filename = 'test.rtf'; system(1, 'c:\\program files\\openoffice\\soffice\\swriter.exe', '-p', + $filename);

      Just a small side note, 'c:\\program files\\openoffice\\soffice\\swriter.exe' might be more nicely written as 'c:/program files/openoffice/soffice/swriter.exe'.

Re: Printing rtf-files with openoffice windows xp
by Ieronim (Friar) on Jul 31, 2006 at 21:55 UTC
    For a more documented and controllable solution than system(1,...), look at the Win32::Process module.

         s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print