Table of Contents

Name

run_ - utility functions to aid running programs in a clean directory

Synopsis


#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);

Description

See also nemo(1NEMO) in the description how to run non-NEMO programs.

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 | exe
style of running a program. The more general run_sh deals with most cases such as
      exe < infile > outfile
with optional infile and outfile

Example

In a typical example, work is done inside of a clean run directory, because alien programs often use a parameter file with a fixed name, and thus cannot easily run side by side in the same directory. Here’s a typical example:
   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

See Also

nemo(1NEMO)

Author

Peter Teuben

History


16-sep-2013    document created    PJT


Table of Contents