FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Red Hat Linux

 
 
LinkBack Thread Tools
 
Old 07-01-2012, 11:01 AM
Claudius Hubig
 
Default startup script

Hello Tony,

Tony van der Hoff <tony@vanderhoff.org> wrote:
> Hi,
>
> I have a script (non gui) which I want to run each time I log in. Which
> is the correct way to do this?

Log in on a TTY/console or into a desktop environment? KDE, Xfce and
GNOME all have autostart settings, other non-DE graphical interfaces
usually use .xinitrc to start things automatically.

If you are on a bare shell, try .bashrc or .profile.

Best regards,

Claudius
--
The best thing about being bald is, that, when unexpected company arrives,
all you have to do is straighten your tie.
http://chubig.net telnet nightfall.org 4242
 
Old 07-01-2012, 11:04 AM
Hormatzhan Yiltiz
 
Default startup script

Put it in your $HOME, create the script with the first line:

#! /bin/bash
# This is your script called myScript
echo "my script is running!"* # you may not need this line!



then put this line in your ~/.profile file:

*** # include .bashrc if it exists
*** if [ -f "$HOME/.myScript" ]; then
*** . "$HOME/.bashrc"
*** fi


On Sun, Jul 1, 2012 at 6:53 PM, Tony van der Hoff <tony@vanderhoff.org> wrote:


Hi,



I have a script (non gui) which I want to run each time I log in. Which

is the correct way to do this?



--

Tony van der Hoff *| mailto:tony@vanderhoff.org

Ariège, France * * |





--

To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org

with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: http://lists.debian.org/4FF02C20.7060604@vanderhoff.org
 
Old 07-01-2012, 01:05 PM
Tony van der Hoff
 
Default startup script

On 01/07/12 13:01, Claudius Hubig wrote:
> Hello Tony,
>
> Tony van der Hoff <tony@vanderhoff.org> wrote:
>> Hi,
>>
>> I have a script (non gui) which I want to run each time I log in. Which
>> is the correct way to do this?
>
> Log in on a TTY/console or into a desktop environment? KDE, Xfce and
> GNOME all have autostart settings, other non-DE graphical interfaces
> usually use .xinitrc to start things automatically.
>
> If you are on a bare shell, try .bashrc or .profile.
>

Thanks, Claudius. This is primarily for KDE, but I would expect it to
work for a console login as well. Does KDE try to run ~/.bashrc or
~/.profile?

The reason I asked here is because I previously tried doing exactly what
you suggest by putting a link in ~/.kde/Autostart to the script, but it
doesn't appear to work.

I don't appear to have ~/.bashrc nor ~/.profile.

Perhaps more detail is required.

I have a script named ~/scripts/start-socks-proxy.sh, containing:
-------------------------------
#! /bin/bash
ssh -CNfqD8080 tony@xxxx.org.uk
-------------------------------

This works fine when invoking from a terminal, or when double-clicking
in konqueror.

As mentioned, I have a link to that script in ~/kde/autostart.
Unfortunately it doesn't autostart.

--
Tony van der Hoff | mailto:tony@vanderhoff.org
Ariège, France |


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4FF04B2B.1040103@vanderhoff.org">http://lists.debian.org/4FF04B2B.1040103@vanderhoff.org
 
Old 07-01-2012, 01:22 PM
Claudius Hubig
 
Default startup script

Hello Tony,

Tony van der Hoff <tony@vanderhoff.org> wrote:
> On 01/07/12 13:01, Claudius Hubig wrote:
> Thanks, Claudius. This is primarily for KDE, but I would expect it to
> work for a console login as well. Does KDE try to run ~/.bashrc or
> ~/.profile?

I doubt that it runs .bashrc, but it may well run .profile. It’s
probably best to try that out yourself by creating a small file
containing the time of execution and maybe the PPID, logging in and
then checking what the file contains

> The reason I asked here is because I previously tried doing exactly what
> you suggest by putting a link in ~/.kde/Autostart to the script, but it
> doesn't appear to work.

Did you try to use the ‘official’ tool?
http://docs.kde.org/stable/en/kde-workspace/kcontrol/autostart/index.html
appears to describe this thing, but I don’t use KDE and hence don’t
know whether it would work for you.

> I don't appear to have ~/.bashrc nor ~/.profile.

Both files should be created from /etc/skel upon creation of your
user profile.

Best regards,

Claudius
--
Tact in audacity is knowing how far you can go without going too far.
-- Jean Cocteau
http://chubig.net telnet nightfall.org 4242
 
Old 07-01-2012, 05:31 PM
rjc
 
Default startup script

On Sun, Jul 01, 2012 at 02:05:47PM BST, Tony van der Hoff wrote:
> Thanks, Claudius. This is primarily for KDE, but I would expect it to
> work for a console login as well. Does KDE try to run ~/.bashrc or
> ~/.profile?

No it doesn't.

Desktop Environments or Window Managers do not run $SHELL startup
files, nor should they.

> The reason I asked here is because I previously tried doing exactly what
> you suggest by putting a link in ~/.kde/Autostart to the script, but it
> doesn't appear to work.

In KDE4 the directory in question is $XDG_CONFIG_HOME/autostart [0] or
$KDEHOME/Autostart [1].

> I don't appear to have ~/.bashrc nor ~/.profile.

Startup files in Bash are a bit of a mess [2] and, contrary to what
others have written here, .bashrc is not read during login (unless
sourced by other files obviously) and if you only log in using X then
you don't need either of those files anyway.

> Perhaps more detail is required.

Perhaps.

> I have a script named ~/scripts/start-socks-proxy.sh, containing:
> -------------------------------
> #! /bin/bash
> ssh -CNfqD8080 tony@xxxx.org.uk
> -------------------------------
>
> This works fine when invoking from a terminal, or when double-clicking
> in konqueror.

There's no reason why it shouldn't.

> As mentioned, I have a link to that script in ~/kde/autostart.
> Unfortunately it doesn't autostart.

And it won't.

P.S. If you'd like your script to run both from X and console login,
put it in KDE's autostart folder and run it from .bash_profile,
.bash_login or .profile (in that order as Bash will stop searching for
the other ones after the first success - told you it's a bit of a mess
;^)

P.P.S. Tony, you sent an email with very little information and got
very imprecise replies. Next time please post one with all required
details, i.e. what kind of login, console or X (and if the latter what
DE or WM), and what are you trying to achieve (i.e. script run at
every shell invocation or only once at logon - .bashrc is the wrong
place to put it BTW). Had you done that the first time around you
might have gotten the right answer to your question the first time
around, otherwise it a bit of a waste of time for us - my crystal ball
doesn't work very well on Sundays for example [3].

[0] if $XDG_CONFIG_HOME is not set it defaults to $HOME/.config
[1] if $KDEHOME is not set it defaults to $HOME/.kde4
[2] http://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/
[3] http://tools.ietf.org/html/rfc1855

Kind regards,
--
rjc


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120701173124.GA6439@linuxstuff.pl">http://lists.debian.org/20120701173124.GA6439@linuxstuff.pl
 
Old 07-02-2012, 03:38 AM
Andrei POPESCU
 
Default startup script

On Du, 01 iul 12, 18:31:24, rjc wrote:
>
> Desktop Environments or Window Managers do not run $SHELL startup
> files, nor should they.

No, but some display managers do
At least gdm (and gdm3 IIRC) and kdm do this, which should cover most
users.

Kind regards,
Andrei
--
Offtopic discussions among Debian users and developers:
http://lists.alioth.debian.org/mailman/listinfo/d-community-offtopic
 
Old 07-02-2012, 09:06 AM
rjc
 
Default startup script

On Mon, Jul 02, 2012 at 04:38:50AM BST, Andrei POPESCU wrote:
> On Du, 01 iul 12, 18:31:24, rjc wrote:
> >
> > Desktop Environments or Window Managers do not run $SHELL startup
> > files, nor should they.
> No, but some display managers do
> At least gdm (and gdm3 IIRC) and kdm do this, which should cover most
> users.

GDM sources /etc/profile and it's only to set environment variables,
and NOT meant to start programs - other sourced files are
distribution-specific.

Regards,
--
rjc


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120702090652.GA17960@linuxstuff.pl">http://lists.debian.org/20120702090652.GA17960@linuxstuff.pl
 
Old 07-02-2012, 05:14 PM
Tony van der Hoff
 
Default startup script

Thanks, rjc, for a very informative post. Unfortunately, my setup (Stock
Debian 6.0.5) doesn't seem to agree with your description.
On 01/07/12 19:31, rjc wrote:
>
>> The reason I asked here is because I previously tried doing exactly what
>> you suggest by putting a link in ~/.kde/Autostart to the script, but it
>> doesn't appear to work.
>
> In KDE4 the directory in question is $XDG_CONFIG_HOME/autostart [0] or
> $KDEHOME/Autostart [1].
>
Neither of those variables is set here, so ~/.config/autostart looks
promising. Sadly, putting the link to my script in there doesn't cause
it to be run on login.

>> As mentioned, I have a link to that script in ~/kde/autostart.
>> Unfortunately it doesn't autostart.
>
> And it won't.

Why not? You chastise me for giving insufficient information, but you're
equally terse
Excuse the typo; it should have read ~/kde/Autostart.

Someone else suggested using the inbuilt KDE autostart tool. That does
actually work, so Im out of the woods, but I'd dearly love to know how
it works. Thank you very much for the suggestion.

>
> P.S. If you'd like your script to run both from X and console login,
> put it in KDE's autostart folder and run it from .bash_profile,
> .bash_login or .profile (in that order as Bash will stop searching for
> the other ones after the first success - told you it's a bit of a mess
> ;^)
>
OK, thanks for the information; I'll try to get it working for KDE login
first.

> [0] if $XDG_CONFIG_HOME is not set it defaults to $HOME/.config
> [1] if $KDEHOME is not set it defaults to $HOME/.kde4

$KDEHOME is not set, but I have no kde4 directory.

> [2] http://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/
> [3] http://tools.ietf.org/html/rfc1855
>

--
Tony van der Hoff | mailto:tony@vanderhoff.org
Ariège, France |


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4FF1D705.2070005@vanderhoff.org">http://lists.debian.org/4FF1D705.2070005@vanderhoff.org
 
Old 07-02-2012, 06:39 PM
rjc
 
Default startup script

On Mon, Jul 02, 2012 at 06:14:45PM BST, Tony van der Hoff wrote:
> >> As mentioned, I have a link to that script in ~/kde/autostart.
> >> Unfortunately it doesn't autostart.
> >
> > And it won't.
>
> Why not? You chastise me for giving insufficient information, but you're
> equally terse

Sorry, didn't mean to be abrupt ;^)

> Someone else suggested using the inbuilt KDE autostart tool. That does
> actually work, so Im out of the woods, but I'd dearly love to know how
> it works. Thank you very much for the suggestion.
> [...]
> > [0] if $XDG_CONFIG_HOME is not set it defaults to $HOME/.config
> > [1] if $KDEHOME is not set it defaults to $HOME/.kde4
>
> $KDEHOME is not set, but I have no kde4 directory.

Hmmm... I assumed it'll be there since KDE4 is the version in Squeeze.

Try here: http://docs.kde.org/stable/en/kde-workspace/kcontrol/autostart/index.html

Regards,
--
rjc


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120702183929.GA23857@linuxstuff.pl">http://lists.debian.org/20120702183929.GA23857@linuxstuff.pl
 
Old 07-02-2012, 07:50 PM
Tony van der Hoff
 
Default startup script

On 02/07/12 20:39, rjc wrote:
>
> Try here: http://docs.kde.org/stable/en/kde-workspace/kcontrol/autostart/index.html
>
Ah, thanks.


--
Tony van der Hoff | mailto:tony@vanderhoff.org
Ariège, France |


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4FF1FB6E.7070604@vanderhoff.org">http://lists.debian.org/4FF1FB6E.7070604@vanderhoff.org
 

Thread Tools




All times are GMT. The time now is 07:03 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org