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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can I do a rexec to execute un C exe ?
# 1  
Old 02-20-2007
Data 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 !
# 2  
Old 02-20-2007
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.
# 3  
Old 02-20-2007
Quote:
Originally Posted by Lika
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 !
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:

HTML Code:
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
# 4  
Old 02-20-2007
Thank you very much for reply !
I will test all tomorrow at work Smilie
# 5  
Old 02-22-2007
Smilie Thank you very much !
I specify environment variables and their values for the program.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Not able to execute an exe file from my location

Hello all, Am facing a peculiar problem, I have copied a utility exe from a bin folder into my local temp folder. I am trying to execute that exe, but it throws out an error saying "No such file or directory". I have given 755 & 777 permissions to it and I tried, but it still throws out that... (6 Replies)
Discussion started by: abhisheksunkari
6 Replies

2. Shell Programming and Scripting

how to execute an exe at startup using rc.local

I want to execute a qt exe program at startup. That is after automatic login instead of loading Desktop and seeing it, the program quickly pop up to the screen. For this, I think we should add the script to rcx.local rather than rc.local I guess though.. I tried adding a script to /etc/rc.local... (0 Replies)
Discussion started by: dr_mabuse
0 Replies

3. UNIX for Advanced & Expert Users

Rexec Issue

Hi Team, I am executing some ksh scripts which inturn calls java files in AIX Environment. We have installed java6_64 which is in .profile. But when we execute from rexec its taking path from some different place that does not have java in $PATH variable. Can you please help me find out which... (2 Replies)
Discussion started by: balasubramani04
2 Replies

4. AIX

rexec - other options?

Rexec executes commands one at a time on a remote host. The rexec command provides an automatic login feature by checking for a $HOME/.netrc file. User and password are stored in $HOME/.netrc. I would like to log on to another host and execute a script/command but not using $HOME/.netrc file,... (4 Replies)
Discussion started by: ioniCoder
4 Replies

5. Programming

c++ : Use of System() to execute .exe with parameters

Hello, I 've trie to execute a a program with parameters unsuccessfully and i take the above message : "The system cannot find the path specified." I used a variaton of the above command : system("\"C:\\xxx\\xxx\\xxx.exe -xxx -xxx xxx.xxx xxx.xxx xxx.xxx\""); Thanks in advance (4 Replies)
Discussion started by: eusta
4 Replies

6. UNIX for Dummies Questions & Answers

launching script via REXEC

Hi folks! my client uses an winapplication which is launching shell-scripts remotely on a HP-Unix Machine via Rexec. The application-configuration is launching the script (which is in the home directory of connecting user) like: rexec host user pass shell.sh So far so good, everything... (3 Replies)
Discussion started by: JohnMurdoch
3 Replies

7. Solaris

Rexec

How is rexec enabled on a Solaris 8? How can I check if rexec is installed? (1 Reply)
Discussion started by: pmj1970
1 Replies

8. Programming

how To edit exe to insert a serial no wich can be usd by runing exe

At time of installation I have to open the resource. and i have to insert a string serial number in the exe. please provide me code to edit the exe (in solaris) to insert a serial number which can be used by exe at run time. (6 Replies)
Discussion started by: ssahu
6 Replies

9. UNIX for Dummies Questions & Answers

Enabling Rexec ????

Can someone tell me how I would enable Rexec on a UNIX machine? And is the procedure different on the different systems - Solaris, HP-UX -etc. Thanks~!! mike (1 Reply)
Discussion started by: raichuu
1 Replies

10. UNIX for Dummies Questions & Answers

expect (re: rexec)

In http://forums.unix.com/showthread.php?threadid=391 there is one statement called expect. but when I issue command whereis expect, respond from o/s only EXPECT: (only one world). I try to find it at /usr/bin, no expect statement there ? is it default unix o/s command ? I am using AIX on... (1 Reply)
Discussion started by: yatno
1 Replies
Login or Register to Ask a Question