Visit Our UNIX and Linux User Community


Error while using alias


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error while using alias
# 1  
Old 09-22-2009
Question Error while using alias

Hi all,
I had set up an alias on CSH.
the alias name I am using in a script.
when I am using -
source scriptName
alias name is getting invoked but when I am trying to run same script using -
./scriptName
aliasname: command not found error is coming.

Any help is appreciated
# 2  
Old 09-22-2009
. filename [arguments]
source filename [arguments]
Read and execute commands from filename in the current shell
environment and return the exit status of the last command exe-
cuted from filename.

you are getting the error because you are executing the file by ./filename

in which another shell is created for execution (not the current shell) because alias is not set for the new shell.


regards,
Sanjay
# 3  
Old 09-22-2009
Thanks sanjay
Some more doubts
Is there anyway I can create a alias which will be used by all the shells as well as newly created also(something like export)?
During surfing I came across "shopt"
will the use of shopt -s expand_alliases help?
I suppose it is only for bash so is there any CSH equivalent available?

Regards,
Milind

Previous Thread | Next Thread
Test Your Knowledge in Computers #833
Difficulty: Medium
YAML version 1.2 is a superset of JSON.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Alias help

I am creating subversion pre commit hook on linux to run on client side but its not working and throwing an error - alias svnbi="plutil *.plist|grep -v OK; if ; then svn ci -m $1 ; fi" but when I run - (test is $1 here) svnbi test bash: syntax error near unexpected token `test' ... (1 Reply)
Discussion started by: jacki
1 Replies

2. 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

3. Shell Programming and Scripting

Trying to setup alias but getting error

Hi All, I am trying to setup an Alias but it's not working properly. Can someone please help ? alias lx='ls -lat | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~//)*2^(8-i));if(k)printf("%0o ",k);print} Thanks, (3 Replies)
Discussion started by: amar0000
3 Replies

4. UNIX for Dummies Questions & Answers

alias

Hello. Q:Is it possible to create an alias for "nedit *. ". If it is how does it look like? Tks. (1 Reply)
Discussion started by: geko
1 Replies

5. UNIX for Dummies Questions & Answers

using alias

I need to login to one server and then switch the user and set a number alias. But i cant modify the .profile file. I have one script avi1.sh $ more avi.sh sudo su - bil sh avi1.sh and in home directory of bil i have avi1.sh that says $ more avi1.sh alias l='ls -ltr' alias b='cd... (7 Replies)
Discussion started by: blackeyed
7 Replies

6. UNIX for Dummies Questions & Answers

alias

Hi, I have created alias in UNIX environment (ie in .cshrc file). But when i use the alias in the UNIX script, getting an error message as that is not found. But when i use that alias, outside the script it is working fine. Let me know if you need more details For example: alias cderror... (6 Replies)
Discussion started by: Naveen_5960
6 Replies

7. UNIX for Advanced & Expert Users

Alias database error

I am running Postfix 2.3 on FreeBSd 6.1 everytime I use the postalias command I get this error message that says no mapping in /etc/mail/mailer.conf hash database is installed and that is what is uncommented out in my main.cf file in the mailer.conf file everthing is pointing ... (0 Replies)
Discussion started by: rbizzell
0 Replies

8. UNIX for Dummies Questions & Answers

alias help

Hi I have a problem when i try to set any thing as alias it works say alias sasa="cd /home/hghgg" but when i close the terminal it does not work (5 Replies)
Discussion started by: shafique
5 Replies

9. UNIX for Dummies Questions & Answers

Alias

I'm trying to do the following: Create an alias called whopw that will change directory to the /etc directory and grep the password file for my username to return my password file entry. One assumption: Once the alias works, I will be letting all of my friends copy and use it. In other... (2 Replies)
Discussion started by: klannon
2 Replies

Featured Tech Videos