How can I do a rexec to execute un C exe ?

Hello,

I would like to do a rexec to execute a C exe (prog.e) :

rexec -l user -p password host prog.e

When I execute this command, I have this error :
prog.e : can not find lib.o

But, When I execute prog.e directly in the remote machine : well done ! No error output.

Thks for your help !

You will have to compile and link prog.e over on the other machine, and keep the executable ONLY over there. It looks like you copied a local version of the program to the remote box. This is not guaranteed to work, by any means.

There are two ways of dealing with this. One way is to compile prog.e statically. You must refer to your compiler documentation to learn how to do this, but you can always just try compiling with "-static" and see what happens.

Unfortunately, some compilers still output an executable which depends on a small shared library, provided with the compiler. So you can always use method two, which is this: Invoke the program as an argument to the env command. The env command allows you to specify environment variables and their values for the program you want to run. You might be familiar with this syntax (from sh, bash, ksh):
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib:/usr/local/lib $PWD/myprogram arg1 arg2
This problem is that this will not work for remote execution -- the rexec command uses these values, but the remote side reinitializes the values. The solution is env:
env LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib $PWD/myprogram arg1 arg2
Works the same way, but now you can prefix your rexec command to the whole thing like this:
rexec -l user -p password host env LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib $PWD/myprogram arg1 arg2

By the way, the "$HOME/lib" is for "demo" purposes only. So here's what you should do in "the general case":
rexec -l user -p password host env LD_LIBRARY_PATH="$LD_LIBRARY_PATH" PATH="$PATH" myprogram arg1 arg2

Since that might be a bit lengthy, you can create a shell function (or script) to do the ugly work for you:

myrexec() { 
  user="$1"
  pass="$2"
  host="$3"
  shift 3
  rexec -l $user -p $pass $host \ 
    env LD_LIBRARY_PATH="$LD_LIBRARY_PATH" PATH="$PATH" \
    "$@" ;  
}

Throw this into your .bashrc file, then you can do:

myrexec username password hostname command arg1 arg2

Good luck

Thank you very much for reply !
I will test all tomorrow at work :o

:slight_smile: Thank you very much !
I specify environment variables and their values for the program.