How to set alias and ps1 in a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to set alias and ps1 in a script
# 1  
Old 05-23-2007
Question How to set alias and ps1 in a script

I am sure this is a newbie question, but I have searched everywhere and cannot find an answer.

My situation is that due security constraints, I cannot modify my .profile file. I have a set of fairly common things that would normally go in the .profile, like setting up alias assignments and setting ps1 to my preferred prompt, etc..

So I basically took what would be my .profile and renamed it to test.sh and run it manually after login. The script runs, but these commands (alias, ps1) don't work. After running I have no alias defined and my prompt does not change. If I take the exact commands from the file and paste them to the command line and run individually, they work fine.

I know that the script is running because if I add commands like echo or ls, they run and produce the correct output.

So, my question is why some commands (echo, ls) work and some (alias, ps1) do not?
# 2  
Old 05-23-2007
When you run test.sh, it ran in a new shell. You should run that in same shell to get alias to use in your current shell
Code:
. test.sh

# 3  
Old 05-23-2007
Thanks a bunch. I knew it had to be simple.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies

2. Solaris

How to set a global alias in UNIX Solaris?

Defined a user alias in unix. Not able to use that alias in a ksh scritp. I dont want to change/source in the script to set the value. Need to set the user alias as a gloabal alias to use it in a new ksh shell window. Can you please help on this? (3 Replies)
Discussion started by: rbalaj16
3 Replies

3. Shell Programming and Scripting

Alias has no effect in script

It doesn't have effect in script but it works on the terminal root@server:/opt/kvm/usecases/logs# alias echo='echo -e' root@server:/opt/kvm/usecases/logs# echo "xxxx\n" xxxx root@server:/opt/kvm/usecases/logs# cat xx.sh #!/bin/bash alias echo='echo -n' echo "sssf \n" ... (3 Replies)
Discussion started by: yanglei_fage
3 Replies

4. UNIX for Dummies Questions & Answers

Create alias files (not alias commands)

If one: $ find -name 'some expression' -type f > newfile and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory. I am... (3 Replies)
Discussion started by: Alexander4444
3 Replies

5. UNIX for Dummies Questions & Answers

Can't find where alias is set

I have an alias set on linux: progs -> /home/user01/prog1.pl the location of prog is changes to /home/user01/new/prog1.pl so I need to modify alias, except I can not find where it is set. It is not in .bashrc or .profile, it is visible by "alias" command. Sorry if it is trivial. (4 Replies)
Discussion started by: analyst
4 Replies

6. Shell Programming and Scripting

Using alias in script

Hi all, Could any one tell me how to use aliases in a script i have a large command which launches an application. I want to use alias in the script because i call the application many time in the shell script. Thanks Firestar. (5 Replies)
Discussion started by: firestar
5 Replies

7. UNIX for Dummies Questions & Answers

kill script using alias name

Hi, I am using the below command to kill the firefox process i have opened in Redhat 5. ps -ef|grep fire|grep -v grep|awk '{print $2}'|xargs kill -9 If i execute the above command in terminal it works good and kills session. but when i use alias for that it is not working. alias... (2 Replies)
Discussion started by: nokiak810
2 Replies

8. Solaris

How to set PS1 in env

Hello whenenver i login to solaris server the prompt is displaying as #. i want to customize the promt with server name for all users. how to customize the PS1 variable for all the users?. Thanks for your help in advance. regards, Saravana (2 Replies)
Discussion started by: tsaravanan
2 Replies

9. Shell Programming and Scripting

Auto Alias Script

Hi All, as you can guess, I'm a newb here, and to shell scripting. I use Linux(CentOS) at home and want to get into scritping. I was creating some aliases on a Laptop the other day, and thought, god this is tedious, and then I thought, heck, why not use it as a 1st script project. Please see... (3 Replies)
Discussion started by: coolboarderguy
3 Replies
Login or Register to Ask a Question