Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Apr 08, 2020 2:45 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Problems with Shell.Execute
PostPosted: Tue Feb 26, 2008 2:11 pm 
Offline

Joined: Tue Feb 26, 2008 2:00 pm
Posts: 5
All,

I am trying to use the shell.execute to run a FORTRAN executable and have some funny results.

I manually fire up a terminal window and type in : ./ExecutableName
This causes the FORTRAN executable to run perfectly.

However, I use RB to : shell.execute "./ExecutableName"
This gives a shared library error for the FORTRAN compiler I am using.

I have checked all of the things that are obvious to me (correct directory, permissions, etc.) I thought the shell.execute command would be exactly the same as doing so manually. I guess I was wrong. Anyone know anything about this??? What is different between the two???

I even tried writting a shell script file and trying to call that using the shell.execute command, but with the same results. I am brand new to RB and like everything up to this point. Also, the shell.execute command works perfectly in the Windows environment (for the Windows FORTRAN executable).

Thanks in advance,
Andy


Top
 Profile  
Reply with quote  
 Post subject: Re: Problems with Shell.Execute
PostPosted: Tue Feb 26, 2008 2:24 pm 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
Location: Canada, Alberta, Near Red Deer
The RB shell does not necessarily inherit the running environment so things like environment variables etc may not be set correctly

Also, running ./executable in the terminal may work but that probably references the wrong location in a shell

_________________
Norman Palardy (Real Software)


Top
 Profile  
Reply with quote  
 Post subject: Re: Problems with Shell.Execute
PostPosted: Tue Feb 26, 2008 2:33 pm 
Offline

Joined: Tue Feb 26, 2008 2:00 pm
Posts: 5
Any fix for the problem??? Environment variables were one of my suspects, but am clueless on how to fix them.


Top
 Profile  
Reply with quote  
 Post subject: Re: Problems with Shell.Execute
PostPosted: Tue Feb 26, 2008 4:58 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Write a script and set up the environment as needed before you run the executable.

Tim


Top
 Profile  
Reply with quote  
 Post subject: Re: Problems with Shell.Execute
PostPosted: Tue Feb 26, 2008 6:03 pm 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
Location: Canada, Alberta, Near Red Deer
there should be very few that are necessary

In terminal you might try typing in "env" and see what they are set to

I'd also try by making sure that instead of using ./Executable you use the full path to it

_________________
Norman Palardy (Real Software)


Top
 Profile  
Reply with quote  
 Post subject: Re: Problems with Shell.Execute
PostPosted: Tue Feb 26, 2008 10:06 pm 
Offline

Joined: Tue Feb 26, 2008 2:00 pm
Posts: 5
Thanks all I will do all of this tomorrow. I am away from my code right now, but for comparison could I type "env" in the terminal window and then run shell.execute "env" and compare the results??? This way I will know what to change to make the shell.execute work correctly.

w102acd


Top
 Profile  
Reply with quote  
 Post subject: Re: Problems with Shell.Execute
PostPosted: Tue Feb 26, 2008 10:46 pm 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
Location: Canada, Alberta, Near Red Deer
should be able to

_________________
Norman Palardy (Real Software)


Top
 Profile  
Reply with quote  
 Post subject: Re: Problems with Shell.Execute
PostPosted: Wed Feb 27, 2008 4:47 am 
Offline

Joined: Thu Jan 26, 2006 8:38 am
Posts: 334
you dont need the ./ in front of it, for example to run a bash script from RB you can type

dim sh as new shell
sh.execute "/path/to/your/script/scriptname"

_________________
Faith is a cop-out. It is intellectual bankruptcy. If the only way you can accept an assertion is by faith, then you are conceding that it can't be taken on its own merits.


Top
 Profile  
Reply with quote  
 Post subject: Problems with Shell.Execute (Resolved)
PostPosted: Wed Feb 27, 2008 10:39 am 
Offline

Joined: Tue Feb 26, 2008 2:00 pm
Posts: 5
Well, I found the culprit, but can't seem to fix it using RB. LD_LIBRARY_PATH

If I run:

Command.Execute "PATH=/usr/local/lf9562/bin:$PATH; MANPATH=/usr/local/lf9562/manuals/man/lf95:$MANPATH; " _
+ "LD_LIBRARY_PATH=/usr/local/lf9562/lib:$LD_LIBRARY_PATH; export PATH MANPATH LD_LIBRARY_PATH; " _
+ "cd " + AppPath + "; ./Scriptname"

The code runs perfectly. I really appreciate everyones help!!!!

Thanks again,
w102acd


Top
 Profile  
Reply with quote  
 Post subject: Re: Problems with Shell.Execute
PostPosted: Wed Feb 27, 2008 11:02 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
It's worth noting here that this is not an RB only issue. When you spawn a shell programatically, the shell aquires the default environment for your user but does not run your login script. Therefore, any custom environment variables in your login script must be set explicitly in the shell.

Tim


Top
 Profile  
Reply with quote  
 Post subject: Re: Problems with Shell.Execute
PostPosted: Thu Feb 28, 2008 9:04 am 
Offline

Joined: Tue Feb 26, 2008 2:00 pm
Posts: 5
Fair enough. Is there an easier more robust fix to the problem then??? Say opening a shell and running the login script prior to running any shell command. This would make sense to me, but, again, I am no Linux expert.

Thanks,
w102acd


Top
 Profile  
Reply with quote  
 Post subject: Re: Problems with Shell.Execute
PostPosted: Thu Feb 28, 2008 10:49 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
No, it's been a problem for as long as I can remember. The problem with running the login script is that it may well try to interact with the user.

Tim


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group