#include <nemo.h> #include <run.h> int run_mkdir(string name); int run_cd(string name); int run_sh(string cmd); int run_popen1(string exe, string file);
This interface encourages a unified approach how to run non-NEMO programs from a NEMO frontend.
In particular, the "runme" script created by runbulgerot(1NEMO) should be employed by all run environments.
The run_popen1 is meant to
simulate the
echo file | exestyle of running a program. The more general run_sh deals with most cases such as
exe < infile > outfilewith optional infile and outfile
string rundir = getparam("rundir");
string exe = getparam("exe");
char tmp[256];
stream fstr;
string cmd = "#! /bin/sh\n"
" rm -rf foobar.dat\n"
" %s <foobar.inp >foobar.log 2>&1\n";
run_mkdir(rundir);
sprintf(tmp,"%s/foobar.dat",rundir);
fstr = stropen(tmp,"w");
fprintf(fstr,"%d",getiparam("n"));
fprintf(fstr,"%g",getrparam("x"));
strclose(fstr);
sprintf(tmp,"%s/%s",rundir,"runme");
fstr = stropen(tmp,"w");
fprintf(fstr,cmd,exefile);
strclose(fstr);
run_cd(rundir);
run_sh("sh runme");
The creation of the "runme" script is not really needed, the run_sh() could
directory use the
16-sep-2013 document created PJT