hi there, i've got this alias i want assign only sometimes, and then work in the same shell with it (so when closing the shell the alias dissapears). As the alias is long, i want it to be in a executable file, so i just execute the script from a terminal and then i can access the alias from that same terminal. I've been playing with alias and export, but after executing the script, the alias is not recognized in the terminal.
any help?
xxx
Last edited by didgewind; 07-22-2012 at 11:32 PM..
Reason: Solved
You'll need to source the file, rather than executing it. If you execute it, the script is run in a child process and the shell that invoked it will not "see" any variables, aliases etc. that are created/changed in the child. By sourcing the file, you cause it to be interpreted by the current shell as though you had entered the commands at the command line.
I would add it to my profile, but assuming you don't want the alias in your .profile, you could create a file in your home directory called .special. When you want to set the alias, execute the following command:
That dot (.) is the source command and will cause the interpreter to parse the named file and process it just as if it had been typed at the command line.
---------- Post updated at 22:37 ---------- Previous update was at 22:36 ----------
Guess we all said the same thing at roughly the same time. Great minds, no?
Hi all,
I have and alias set in .profile like
alias ll='ls -la'
I am writing a shell script in which i am using "ll" but it gives command not found . Can anyone please tell me how source aliases in the script we write do i need to define it again in every script i write is there any oher... (1 Reply)
hi, I am trying to create a script in AIX (5.3 I think), then run it. here's what I have:
/home/me $ vi first.aliases
...
alias cdblah='cd /blah'
alias cdho='cd /ho'
alias ssr='sudo su - random'
~
...end of first.aliases
/home/me $ ./first.aliases
/home/me $ ssr
ksh: ssr: not found.... (2 Replies)
I have four files a,b,c,d which need to contain certain in the sequence a, b, c ,d , each file command which needs to be executed,
what i m in need is that to executed file and cmd in the defined order and if any of the command FAIL or throw ERROR, it script shud come out... (3 Replies)
Hello:
i have several server with own etc aliases. right now i want to combine it all into a general etc aliases in a new freebsd server. cause it consist hundred thousand of record user inside how to make a shell script to combine it or configure it.
all etc aliases record example: ... (0 Replies)
I have directory/dns server running sparc solaris 9.
while troubleshooting another issue, i overwrote the aliases file on accident.
my question is: is there any way to revert this?
any help super appreciated...especially since this a production box! (2 Replies)
Can any one show me how to create an alias account that silently copies local emails to the administrator (root) using a linux cmd line or GUI?
The answer needs to be very simplly explained at this stage, as I am new to the command prompt...expecialy in linux.
thanks heaps guys
Pipa:)
I... (2 Replies)
Hi
How can i dynamically read files names from a list file and execute them from a single shell script.
Please help its urgent
Thanks in Advance (4 Replies)
Hi.
I have a C program that is using the **environ pointer and I am trying to set up aliases for a system("/bin/ksh") call. This works for other environment variables but not for the aliases. Does anyone know if this can be done? Thanks ahead of time. (1 Reply)