javascript - nsIProcess with arg with quote not getting created -



javascript - nsIProcess with arg with quote not getting created -

i'm trying run little routine convert .doc word files (using libreoffice) html. when run on command line, works, not through nsiprocess:

var cc = components.classes; var ci = components.interfaces; var sofficepath = ('c:\\program files (x86)\\libreoffice 4.0\\program\\soffice.exe').replace(/"/g, ''); var path = 'c:\\users\\brett\\appdata\\local\\temp\\brl-downloader6.doc'; function createprocess (path, args) { var ansifile = cc['@mozilla.org/file/local;1'].createinstance(ci.nsilocalfile); ansifile.initwithpath(path); var process = cc['@mozilla.org/process/util;1'].createinstance(ci.nsiprocess); process.init(ansifile); process.runasync(args, args.length, null); } createprocess(sofficepath, [ '--headless', '-convert-to', 'html:"html (starwriter)"', path.replace(/"/g, '') ]);

i think related quotation mark in html:"html (starwriter)" argument, i'm not sure how around it.

i tried no effect (single or double quotes give errors libreoffice , next ignored not convert file):

'--headless -convert-to html:"""html (starwriter)""" ' + path.replace(/"/g, '')

what going wrong?

nsiprocess (windows) "escape" arguments, is:

if argument contains white-space wrap in " quotes. if argument contains \ backspaces , or " quotes, escape \.

you're double-escaping html:"html (starwriter)" string. utilize html:html (starwriter).

another problem encountered re-create of libreoffice (4.2) write file current working directory, in case of firefox c:\program files (x86)\mozilla firefox , not writable. improve provide -outdir.

this worked in scratchpad me (note changed paths code):

var cc = components.classes; var ci = components.interfaces; var sofficepath = ('c:\\program files (x86)\\libreoffice 4\\program\\soffice.exe').replace(/"/g, ''); var path = 'c:\\temp\\test.odt'; function createprocess (path, args) { var ansifile = cc['@mozilla.org/file/local;1'].createinstance(ci.nsilocalfile); ansifile.initwithpath(path); var process = cc['@mozilla.org/process/util;1'].createinstance(ci.nsiprocess); process.init(ansifile); process.runasync(args, args.length, null); } createprocess(sofficepath, [ '-headless', '-convert-to', 'html:html (starwriter)', '-outdir', 'c:\\temp', path.replace(/"/g, '') ]);

producing command line (watched in process monitor):

"c:\program files (x86)\libreoffice 4\program\soffice.exe" -headless -convert-to "html:html (starwriter)" -outdir c:\temp c:\temp\test.odt

anyway, html (starwriter) filter not necessary, html works fine me (and produces same output).

javascript firefox-addon

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -