PDA

View Full Version : Whats wrong with this script -- help needed



swamyonline
29th June 2009, 14:06
hi,
In the process of deploying Qt-4.5.1 application on RHEL5 built with bitrock install builder, the installer is executing a script to change environment variables. the script looks like this.

script file name : myscript.sh


#!/bin/bash
export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH
export PATH=$PWD:$PATH

As compiler related and Qt library files are also present the application directory, I am trying to set library and executable path to application directory.
when i ran that script, even from console externally, I not getting any error, but the environment variables are not at all changed. But when i do the following at the prompt, its getting set for the session and vanishing after i close the console and reopen it again.


#export export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH
#export PATH=$PWD:$PATH


where is the problem?
how can i set/ change environment variables through my Qt application permanently?

I have also tried the following in my Qt application


int main(..)
{
.....
QApplication::addLibraryPath("$PWD");
......
}

Im not successful with any of those option.. pls suggest your valuable points.

my Qt application will run on Linux as well as on Windows (with mingw compiler).

thank u very much in advance.. pls post ur suggestions.

AcerExtensa
29th June 2009, 14:22
Have you tried gentenv & setenv?
QApplication::addLibraryPath(getenv("PWD"));

swamyonline
30th June 2009, 17:26
thanks fr ur reply Acer. i tried that also,but nothing happened. by searching i learned that,the script is forking another process whose env wil vanish once it comes out of execution. i tried to set env vars for my app just before it starts executing.i think the only alternative is to edit the /etc/bashrc file and change the required vars through some API in my qt app itself.can somebody pls let me know how can i edit /etc/bashrcthru qt or 'C' ?

wysota
30th June 2009, 20:59
how can i set/ change environment variables through my Qt application permanently?

You can't. The environment you have in the application is a copy of the environment the parent process had. Once you end your application its environment will be destroyed and the parent will still have the same environment it had before launching your application.

NoRulez
1st July 2009, 08:22
Hi swamyonline,

This has nothing to do, but why do you use non-RPM if you work on RHEL5. This has the advantage that it also resolves dependencies.

If you need help in building rpms don't be shy to sent me a PM.
I use it for many projects.

Kind Regards
NoRulez

swamyonline
2nd July 2009, 14:17
hi NoRulez,

thanks for your reply. me shy? not at all when learning new things. yes, i desperately need such an implementation. pls suggest your points. eagerly looking forward. thanks again. bye