http://qs321.pair.com?node_id=688296


in reply to how to run your program when the system is started....

(Not exactly a Perl question, but often puzzles unix/linux newbies.)

Two things here. The first one:

how to make a program run as soon as linux is being started

... is usually beeing accomplished by putting the program invocation into the appropriate startup file, most probably (you mentioned "Linux" which one?) the file etc/init.d/boot.local, like mine:

$> cat /etc/init.d/boot.local

starts the cpu temperature sensors package:

#! /bin/sh modprobe w83627hf sleep 1 # optional /usr/bin/sensors -s

the other question was:

how to make my program run atomatically as as soon as somebody log into the linux system

Same thing here, put the command into the appropriate file, for bash login shell, this might be the file ~/.bashrc in your home directory.

For example, you have a program called 'anonymoushydrogen.pl' in your home directory, which contains the following code:

#!/usr/bin/perl print "Hello anonymoushydrogen!\n";

then, you may put the command:

perl ~/anonymoushydrogen.pl

into your .bashrc and all is fine.

But: the exact name of the file may depend on your shell or login configuration (.bashrc, .profile, .bash_profile etc.).

Regards

mwa