Can we use aliased commands in script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can we use aliased commands in script?
# 1  
Old 01-10-2006
Can we use aliased commands in script?

Hi All,
I need a small help.. when we use aliased commands in shell script, they are not being recognized when I used. Is there any way to use aliased commands in scritping? Please let me know if u know...

Thank you
Chanu
# 2  
Old 01-10-2006
you need to load your alias' available in your .profile to the script that is run

Code:
# !/usr/bin/ksh

. $HOME/.profile

<check_with_your_alias>
<ideally_should_work>

exit 0

# 3  
Old 01-11-2006
Thanks for that but my question is can we use the aliased commands in our script... for example

in $HOME/.bashrc it is defined as

alias h='history'

and in one of the shell scripts if "h" is used, it is an error.. is there any way to use aliased commands in our scripts or it is not possible at all...
# 4  
Old 01-11-2006
deleted.............

Last edited by mahendramahendr; 01-12-2006 at 02:20 PM..
# 5  
Old 01-11-2006
Now i will explain u in detail..

in my .bashrc i alised getip1, getip2, getip3 and my script is simple command

getip$*

save with name "getip".

when i run the script as getip 1 2 3 expected output is it has to run getip1, getip2 and getip3 but error is "getip1: command not found" ..

After ur suggestion i changed the script to

. $HOME/.bashrc
getip$*

even then same error.. do needful...ok
# 6  
Old 01-11-2006
include the line #!/usr/bin/ksh as your first line in the script, it will work
# 7  
Old 01-11-2006
even now it is not working...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using commands within bash script

The purpose of enclosed script is to execute selected command and output success or failure in whiptail msgBox Works as expected when command returns zero to msgBox. I cannot figure out how to continue / automate my script when command expects reply to continue / terminate. I am doing it... (2 Replies)
Discussion started by: annacreek
2 Replies

2. UNIX for Dummies Questions & Answers

UNIX commands for a script that I need

Hello. I need help trying to create a script in UNIX to do the following steps. I don't know which commands to input to achieve this. 1. In a directory tree, I want to duplicate all .txt files into the same directory, so 2 of each file exists in each directory where there is a .txt file ... (4 Replies)
Discussion started by: TitanTlaloc
4 Replies

3. Shell Programming and Scripting

Issue commands within script

What is the best way of having a script that has it's own commands, which can be called at any stage in the script. I'm sure there is a technical term for this type of CLI app which can help my search but I can't remember it. Is using trap the best way of doing this. (6 Replies)
Discussion started by: cue
6 Replies

4. Shell Programming and Scripting

Commands in background in a script

Hi, I was writing a script for backup,however i stumbled upon this.( As i mentioned in my earlier posts iam a beginner in shell scripting). Here is a piece of code case $DB_STAT in OFFLINE) echo "Service $SID currently $DB_STAT" ... (1 Reply)
Discussion started by: maverick_here
1 Replies

5. Shell Programming and Scripting

How to make a script out of commands

Hi, I have a very basic knowledge of Unix and I need your help for a small script that will do the following commands that I do manually by just giving the filename TPR20080414.txt cut -d'|' -f3,4 TPR20080414.txt> oe_012.lkp awk -F "|" '{temp=$1;$1=$2;$2=temp}1' OFS="|" oe_012.lkp >... (3 Replies)
Discussion started by: sickboy
3 Replies

6. Shell Programming and Scripting

running commands from script

I'm new to unix and I have a fairly simple problem: Lets say I am in a specific directory and I run the command: "dirs" , I get an output of all the folders that i pushed into the stack (as expected), buut, when when I create a script (called test): #! /bin/csh dirs and then i run:... (2 Replies)
Discussion started by: owijust
2 Replies

7. Shell Programming and Scripting

Repeating commands in a script

I have written a script that I want to be repeated. The script that I wrote outputs the date, how many people are on the system, how many people logged in before me, and how many people logged in after me. Than what I want it to do is after it outputs the 4 lines I want it to go back to the... (4 Replies)
Discussion started by: Dave2874
4 Replies

8. UNIX for Dummies Questions & Answers

script commands

my bad (2 Replies)
Discussion started by: romeoz
2 Replies

9. Shell Programming and Scripting

vi Commands in a Script

Perhaps there is a better way to do this, but right now this is all I can think of. If there is a better way to do this, all suggestions are welcome. I would like to take a file and perform the following actions on it. 1. Search for CREATE TABLE 2. Copy that line and paste it one line... (7 Replies)
Discussion started by: djschmitt
7 Replies

10. Shell Programming and Scripting

calling a aliased variable

Issue: i have variable A which is an alias for variable B which is equal to "THIS IS A TEST" when every i echo variable A i only get the alias name for variable B, NOT the contents of variable B. HOSTNAME# echo $TESTIT + echo THIS IS A TEST THIS IS A TEST HOSTNAME# ls -l total... (10 Replies)
Discussion started by: Optimus_P
10 Replies
Login or Register to Ask a Question