Re: [Linuxcommand-discuss] aliases in scripts
Brought to you by:
bshotts
From: William S. <wes...@co...> - 2002-08-07 00:32:26
|
On Tuesday 06 August 2002 04:59 pm, William Shotts wrote: > That is a really interesting question. I have noticed on my RH box that > scripts do inherit the aliases of the user. I saw where this was > controlled once, but I can't remember where. I would perfer the > behavior you describe since it would make the execution environment > more predictable/secure. Perhaps one of our more enlightened members will > know the answer. > > ||||| William Shotts, Jr. (bshotts AT panix DOT com) > ||||| Be a Linux Commander! Follow me to http://linuxcommand.org > > On 6 Aug 2002, Mertens Bram wrote: > > Hi, > > > > I added some aliases to my ~/.bashrc file like > > alias lh='ls -lh' > > and restarted my konsole to activate the changes (which works fine) but > > now I tried to call that alias from a script and I get: > > /home/M8ram/bin/bu: lh: command not found > > > > Is this because shell scripts are executed in a non-interactive shell? > > > > Is it possible to use aliases in scripts? (Without defining them in the > > script? > > > > I know I'm being really lazy! :))) > > > > Thanks > > -- > > > > | Mertens Bram "M8ram" <bra...@li...> > > | Registered [Red Hat] Linux User # 249103 since Octobre 2000 > > | http://linux.be | http://www.redhat.com | http://counter.li.org > > > > \____________________________ > > Jeez! What was I thinking? You can easily do what you want by including the following line near the beginning of your script: . ~/.bashrc The leading dot and space are important. They are shorthand for the source command. Source reads a file and includes it in your script. It is useful for including libraries of common functions, constants, etc. This will work your scripts but probably would not be useful for scripts shared by other users. To solve this problem, you should look at /etc/bashrc and /etc/profile files which provide the common environment for all users. -- ||||| William Shotts, Jr. (bshotts AT panix DOT com) ||||| Be a Linux Commander! Follow me to http://linuxcommand.org |