How do i call aliases from my .profile?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do i call aliases from my .profile?
# 1  
Old 10-17-2014
How do i call aliases from my .profile?

Hello all,

Please my shell is ksh. I created .profile such that users can pick environments they want to use:

Code:
echo Select your Environment!!

echo " 1. Nigeria DEV"
echo " 2. UEMOA DEV"
echo " 3. CEMOA DEV"

echo "Make your choice : \c"
read choice

if [ $choice = 1 ]
then
...
fi

if [ $choice = 2 ]
then
...
fi

Also i have different aliases files for each of those environment:

.aliases_UE
.aliases_NG
.aliases_CE

Please can someone just tell me how to call each aliases of its environment within the if clause ... I have tried using:

Code:
if [ $choice = 1 ]
then
...
. .aliases_NG
...
fi

It didn't work.

Thank you.
# 2  
Old 10-17-2014
Quote:
Originally Posted by mofaloks
Code:
if [ $choice = 1 ]
then
...
. .aliases_NG
...
fi

It didn't work.
How didn't it work? Did you get an error, or what?
# 3  
Old 10-17-2014
Hi CarloM,

The aliases doesn't work after the .profile is run. For example, an alias is
Code:
alias l='ls -lrt'

. If after you run the .profile, and you do
Code:
l

at a prompt, it doesn't list. Same goes for all other alias shortcuts, they don't work.

Code:
/finusers/UBADEV> l
ksh: l:  not found.

Thanks.
# 4  
Old 10-17-2014
Hi,

what do you see if you just type
Code:
alias

at a command prompt.

Regards

Dave
# 5  
Old 10-17-2014
When you say "run the .profile" how did you do this?
You have to source the profile in order to make it affect your current shell (like you did when you invoked the alias scripts in .profile):
Code:
. .profile

# 6  
Old 10-17-2014
gull04,

Code:
[UBADEVNG/FINCORE]>/finusers/UBADEV> alias
autoload='typeset -fu'
command='command '
functions='typeset -f'
hash='alias -t -'
history='fc -l'
integer='typeset -i'
local=typeset
nohup='nohup '
r='fc -e -'
stop='kill -STOP'
suspend='if [[ ${0#-} = $0 ]] ; then kill -STOP $$; else dspmsg -s 1 ksh.cat SUSPEND "suspend: cannot suspend login shell
"; fi '
type='whence -v'

---------- Post updated at 02:36 PM ---------- Previous update was at 02:35 PM ----------

cero,

yes that's how i ran (or source) the .profile
# 7  
Old 10-17-2014
Quote:
Originally Posted by mofaloks
Code:
if [ $choice = 1 ]
then
...
. .aliases_NG
...
fi

It didn't work.

Thank you.
not much to go on, so just a shot in the dark:

try:

Code:
 
. ./.aliases_NG

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Attemp to call the .profile

i have this line of code on my script #!/bin/sh #enable the environment variable thru profile . .profile when i run the script it was unable to find the .profile sh ChgPwd.sh ChgPwd.sh: line 4: .: .profile: file not found the file .profile exists ls -altr .profile... (2 Replies)
Discussion started by: wtolentino
2 Replies

2. Shell Programming and Scripting

Auto transfer all aliases from one profile to another

Hi, I login to Linux and Solaris server using my personal user account "ms1104" . I have several aliases set in my profile. Later i need to switch to another user account i.e. "wlsuser" and below is the command i use sudo -u wlsuser -s -H i do not have authority to modify the... (1 Reply)
Discussion started by: mohtashims
1 Replies

3. UNIX for Advanced & Expert Users

Can we call crontab -e into .profile?

Hi All, I have a doubt that can we call under whatever scripts we mention in crontab -e into .profile . Because every weekend my server is going to restart so, my doubt whether crontab -e will automatically run my scripts or manually we have to save the crontab -e again? If that crontab... (3 Replies)
Discussion started by: ksrivani
3 Replies

4. Shell Programming and Scripting

Call .profile in perl script

Hello Gurus Can anyone please let me know how to call .profle file in perl script When I am calling the .profile file its giving error Shall I create unix script which has .profile command and call perl script internally (2 Replies)
Discussion started by: Pratik4891
2 Replies

5. Infrastructure Monitoring

trap in etc/profile and user .profile

Hello I really wonder what's trap in etc/profile and in each user .profile. I try to google for it but I think I have no luck. Mostly hit is SNMP traps which I think it is not the same thing. I want to know ... 1. What's a "trap 2 3" means and are there any other value I can set... (4 Replies)
Discussion started by: Smith
4 Replies

6. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

7. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies

8. Shell Programming and Scripting

How to call .profile in cron?

Hello all, I want to call my users .profile in cron? I understand that i have to do it explicitly in crontab entry. How can we do it ? How can i write a simple script calling it? Thanks & Regards Abhijeet (15 Replies)
Discussion started by: abhijeetkul
15 Replies

9. Programming

aliases

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)
Discussion started by: mluey61
1 Replies

10. UNIX for Dummies Questions & Answers

changed .profile but didnt ./.profile, yet reflected changes

hi , i added ls -F to .profile. and i need to do ./.profile for the effect to take effect BUT i didnt and YET the next day when i came to work and log in, the changes took effect. i am on aix. please explain.. thanks (4 Replies)
Discussion started by: yls177
4 Replies
Login or Register to Ask a Question