Calling a script from within rc.local does not work.
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm guessing that rc.local, like any scripts in /etc/rc.d (or /etc/init.d for that matter) only get executed when the runlevel changes. So, yes, the script probably does run and sources your aliases stuff.
However, the aliases settings are not retained to your login shell probably.
So, when you start a shell, you will not inherit them either.
To fix this, put the "source ..." command not in /etc/rc.local but rather in /home/you/.profile, /home/you/.<your_shell>rc (ie /home/you/.bashrc) if they are only to be applied to your user. If you want to apply the aliases for all users, put them in /etc/profile or /etc/<some_shell>rc (ie /etc/bashrc).
If you want the user oferu to be able to use those aliases, you should probably place the commands in /home/oferu/.profile, /home/oferu/.bash_profile or /home/oferu/.alias, depending on your configuration. There's also a file for system-wide settings like these (probably /etc/profile).
Edit: Well, at least the answer I gave looks similar to that of timmeke
Last edited by spirit receiver; 06-08-2006 at 02:45 AM.
1st: remove the first line from "/home/oferu/aliases" which is "#!/bin/sh"
2nd: instead of "source /home/oferu/aliases" use ". /home/oferu/aliases" (dot space filename), this is the include statement for bash.
it should work this way.
edit: NOTE: source command will execute the command line given to it and exit (like exec command), any commands below the source command in your rc.local will not be executed.
1st: remove the first line from "/home/oferu/aliases" which is "#!/bin/sh"
Any line beginning with a # will be ignored, even if the file is being sourced. The presence of this line shouldn't be a problem.
Quote:
source command will execute the command line given to it and exit (like exec command), any commands below the source command in your rc.local will not be executed.
This is not so. An excerpt from the bash texinfo manual:
Code:
`. (a period)'
. FILENAME [ARGUMENTS]
Read and execute commands from the FILENAME argument in the
current shell context. If FILENAME does not contain a slash, the
`PATH' variable is used to find FILENAME. When Bash is not in
POSIX mode, the current directory is searched if FILENAME is not
found in `$PATH'. If any ARGUMENTS are supplied, they become the
positional parameters when FILENAME is executed. Otherwise the
positional parameters are unchanged. The return status is the
exit status of the last command executed, or zero if no commands
are executed. If FILENAME is not found, or cannot be read, the
return status is non-zero. This builtin is equivalent to `source'.
The source (or .) command will not prevent the rest of your script from executing.
As timmeke and spirit receiver have noted, aliases set from within a startup shell script (or any shell script, for that matter) will not be inherited by the login shell.
Simply moving the source (or .) line into /etc/profile or ~/.profile will solve your problem.
Last edited by zhangmaike; 06-08-2006 at 03:36 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.