This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] bashrc execution

Tags: None
(comma "," separated)
xrfang
Registered Member
Posts
10
Karma
0
OS

[SOLVED] bashrc execution

Tue Apr 07, 2009 8:03 am
I run a script in bashrc, and arrange it to be run once a day on the first time I open a terminal window.

This works well in gnome, but after I switch to KDE, the script seems to be run at the time I login!

The script uses network and will download quite some data, running it on login will make the login process very slow...

Could anyone tell me how to prevent bashrc to be parsed on login, or, is there any other RC file I can run my script?

Thanks!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

[SOLVED] bashrc execution

Tue Apr 07, 2009 8:28 am
I would recommend splitting the script out to a secondary file, then setting the following as your shell for a profile in Konsole:
/bin/sh -e


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
xrfang
Registered Member
Posts
10
Karma
0
OS

[SOLVED] bashrc execution

Tue Apr 07, 2009 4:29 pm
My script is already in another file. Unfortunately your suggestion does not work. After I change konsole profile, it simply does not open properly. I have to change that back in .kde/.../...

I tried to follow your hint and read bash's man page, I tried to use the --rcfile switch, that successfully called my script, but makes it fail, because in my script, I use:

cp=$(dirname -- "$0")/ids.jar

to set the classpath of a java application, after using --rcfile switch, the $(dirname -- "$0") does not work anymore, it does not point to the path of my script, but point to /bin, because $0 is now bash itself!

I am still thinking for a solution, if you know any alternatives, please let me know. Thank you very much!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

[SOLVED] bashrc execution

Wed Apr 08, 2009 5:33 am
Oops. Try setting the Konsole shell as the script itself.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
xrfang
Registered Member
Posts
10
Karma
0
OS

[SOLVED] bashrc execution

Wed Apr 08, 2009 2:04 pm
bcooksley wrote:Oops. Try setting the Konsole shell as the script itself.


I am sorry but that did not work either. However maybe I did something wrong. I tried to set the "Command" of the Konsole profile to:

/usr/bin/konsole -e sh /home/xrfang/ids/daily.run


or

/usr/bin/konsole -e /home/xrfang/ids/daily.run


both of the above did not work. If I try open a konsole in an already opened one, it report the following error on command line:
Qt: Cannot set locale modifiers:
konsole(21914): Attempt to use QAction "change-profile" with KXMLGUIFactory!


I found this in the forum:

kdm-does-not-execu ... 34156.html

which was reported as a problem, but in fact I would like to instruct kdm NOT to execute .bashrc, or, alternatively, how can I know within .bashrc that its caller is KDM or not so that I can do things accordingly.

Thanks!
xrfang
Registered Member
Posts
10
Karma
0
OS

[SOLVED] bashrc execution

Wed Apr 08, 2009 3:53 pm
The problem is now solved. I found a simple method by google, to detect if bashrc is called by kdm or not, if not, then run my script:

Code: Select all
true=`echo $(dirname -- "$0") |grep kdm`
if [ -z $true ]; then
  //run my script here
fi


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, mickae, Sogou [Bot]