[rkward-devel] system calls with JS?
meik michalke
meik.michalke at uni-duesseldorf.de
Wed Mar 10 19:54:41 UTC 2010
hi thomas,
am Mittwoch 10 März 2010 (20:14) schrieb Thomas Friedrichsmeier:
> hmm, that is not currently possible from JS.
happy to read this -- at least i haven't overseen it ;-)
> Would it be possible to use R code for that, instead?
yes and no: R can do system calls, and it actually does that later in my
plugin. on the other hand, the previous PHP system call is used to check paths
to the needed executables, to then *generate* the R system calls with the
collected information (see below).
what i want: generate LaTeX output in an temp folder, call pdflatex on those
files and probably pdftk to glue them together to one file. i'd gladly do it
all without calling external binaries, if there's a way.
i must admit that my approach here is kind of, hmmm, experimental... maybe no
one (with the exception of me) will ever need that. but to me it's very handy.
> This would potentially have the added benefit of making the
> generated code more portable.
that would be great -- right now pdf generation will only work with a hand
full of unix commands.
> If that suggestion does not sound good to you, could you post a couple of
> example lines to make it easier to discuss the details?
you can try the whole thing, if you like. this is the rkward-plugin:
o http://r.reaktanz.de/klausuR_rkward/klausuR_rkward-0.9-3.tar.gz
it includes a .pluginmap you can just add for testing. of course it won't
really work without the klausuR R package (which is available as well), but if
you toggle the checkboxes concerning pdf, you can at least see how it behaves.
a critical part goes something like this:
<code>
// get paths for the needed command line tools
$cmd_mktemp = exec("which mktemp");
if($cmd_mktemp == "") $cmd_mktemp = "FAILED!";
$cmd_pdflatex = exec("which pdflatex");
// check if they're installed at all
if($chk_pdf_pdftk){
$cmd_pdftk = exec("which pdftk");
if($cmd_pdftk == "") $cmd_pdftk = "FAILED!";
} else $cmd_pdftk = "(not used)";
if($cmd_mktemp == "FAILED!" || $cmd_pdflatex == "FAILED!" || $cmd_pdftk ==
"FAILED!"){
// if they can't be found, give an error and reset $chk_pdflatex
echo("## SORRY, can't invoke pdf generation.\n".
"# path to mktemp:\t".$cmd_mktemp."\n".
"# path to pdflatex:\t".$cmd_pdflatex."\n".
"# path to pdftk:\t".$cmd_pdftk."\n");
$chk_pdflatex = FALSE;
} else {
// if all tools are found, create temp directory first
echo("# OK, found these tools for pdf generation:\n".
"# path to mktemp:\t".$cmd_mktemp."\n".
"# path to pdflatex:\t".$cmd_pdflatex."\n".
"# path to pdftk:\t".$cmd_pdftk."\n#\n");
?>
# create a tempdir, to later run pdflatex on the LaTeX files
pdf.build.path <- try(system("TMPDIR=${TMPDIR:-/tmp} ; <? echo($cmd_mktemp);
?> -d \"$TMPDIR/tmp.XXXXXXXXXXXXX\"", intern=TRUE))
</code>
viele grüße :: m.eik
--
dipl. psych. meik michalke
institut f"ur experimentelle psychologie
abt. f"ur diagnostik und differentielle psychologie
heinrich-heine-universit"at 40225 d"usseldorf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20100310/e29a7342/attachment.sig>
More information about the Rkward-devel
mailing list