[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Edlug Archive Mar 2004 ]

Re: [edlug] Trouble With Scripts




Keith W Wyse wrote:
I wonder if anyone can answer this question;
I've been trying to create a script which will alias a word with a
command with the simple line

#!/bin/bash -v
alias someword='/somepath/somecommand &'

Unfortunately when I list the aliases in the gnome-terminal window after
having run the script, the alias does not exist.

You need to understand how the shell runs shell scripts to get this working properly.


	GNU terminal runs bash
		That bash runs new bash to run script.
		New bash runs alias and sets it.
		New bash reaches ebd of script and exits.
	You are now back at the bash in the Gnu terminal.
	No alias has been set in this bash.

You need to either tell the gnu terminal bash to run the contents of the script directly

	. ./scriptname
Or in some shells including bash
	source ./scriptname

The other bay is to put the alias in your $HOME/.bashrc
It will then get picked up by new bashes when they start up.
	Robert.


- ---------------------------------------------------------------------- You can find the EdLUG mailing list FAQ list at: http://www.edlug.org.uk/list_faq.html



This archive is kept by wibble@morpheux.org.DONTSPAMME
homepage