Bourne: How to invoke an alias from within a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bourne: How to invoke an alias from within a shell script
# 1  
Old 05-02-2005
Bourne: How to invoke an alias from within a shell script

Bourne: How to invoke an alias from within a shell script


If I type in the alias in the command line, it runs

If I insert that same alias into my shell script and run the shell script, the alias is not invoked.

Help please.
# 2  
Old 05-02-2005
Exporting aliases is shaky at best, and what can be achieved can only be achieved with the Korn shell, not Bourne.

See this.

Here is an excerpt...

Exporting aliases works in much the same way as exporting variables with export. But, ksh will only export an alias to another shell that is not a separate invocation of ksh (an exported alias will survive a fork(2), but not an exec(2)). Exported aliases are available to subshells, for example, ( prog ), and to shell scripts that do not start with #!/bin/*.

You can export aliases interactively or from within your .profile or .kshrc. To do so type, or add to the appropriate file:

alias -x who='who | sort'

Then, when you type alias or alias -x, who=who | sort is shown.

Cheers
ZB
# 3  
Old 06-04-2006
This is quite old thread though, but stillI want to know about few concepts here, like what is meant by:
Quote:
1)an exported alias will survive a fork(2), but not an exec(2))
2)Exported aliases are available to subshells, for example, ( prog )
3)shell scripts that do not start with #!/bin/*.
Regards,
Tayyab
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Alias is not working under Bourne Shell

Hi, Please assist me why HC alias is not working under this shell? root@singapore # grep HC /.profile alias HC='cd /var/tmp/HC/2015/`date +%B`' root@singapore # . /.profile Sourcing //.profile-EIS..... root@singapore # echo $HC root@singapore # HC HC: not found root@singapore # echo... (18 Replies)
Discussion started by: tprabhu1983
18 Replies

2. AIX

Alias Command in Bourne Shell

Hi My Unix sever is AIX 5.3. My Login shell ( using echo $SHELL) is /bin/sh implying it is a Bourne Shell. My Question is that i am still able to use Alias command to create/retrieve aliases. I have read in several sites on Unix online that the Bourne Shell does not support Aliases but... (12 Replies)
Discussion started by: pchegoor
12 Replies

3. Shell Programming and Scripting

help with bourne shell script

Attempting to write a script to eventually notify me via email for when there is packetloss across the backbone. I am looking for values greater than 0% in the mtr field. #!/bin/sh target=www.google.com date +"%D"_"%T" >> /home/rich/mtr.log echo "----------------------------------------" >>... (1 Reply)
Discussion started by: closedown
1 Replies

4. UNIX for Dummies Questions & Answers

Invoke a shell script on new email in inbox

Hello all, Is there a way I can invoke a shell script when ever a new mail is delivered to my account in solaris? Something like .forward file, instead of forwarding it to another email id, I want the email to be passed onto some shell script. Basically I want to extract the envelop... (3 Replies)
Discussion started by: atukuri
3 Replies

5. Shell Programming and Scripting

Shell script to invoke options automatically

i have a script which has 2 options. a b And a has 6 sub options. i want to write a script which will call the parent script and give options automatically. examle: linasplg11:/opt/ss/kk/01.00/bin # startup.sh /opt/ss/rdm/01.00 Please select the component to... (2 Replies)
Discussion started by: Aditya.Gurgaon
2 Replies

6. Shell Programming and Scripting

How can i invoke SU command in shell script

Hi All , i am trying to switch user (from unix1 to unix 2 ) The user will give me the input and also the password . also how can i login into with the password . itried several attempts . no luck Can any one help on this !!! (4 Replies)
Discussion started by: raghav1982
4 Replies

7. Shell Programming and Scripting

Shell script to invoke db startup/shutdown

Hi all, I have a shell script which does db shutdown ..the script snippet which does this is as follows: function call_sql_plus { ${SQLPLUS:-sqlplus} -s /nolog <<EOF EXIT; EOF if then echo "Error occurred while calling sqlplus " ... (3 Replies)
Discussion started by: KrishnaSaran
3 Replies

8. UNIX for Dummies Questions & Answers

need to invoke a shell script from xml file.

hi all, forgive me if this question is not relevant to this section. i have a shell file that will automatically deploy the files that are necessary and will compile them. i need to automate this management process through cruise control, for this i need to know whether it is possible for me to... (2 Replies)
Discussion started by: sais
2 Replies

9. Shell Programming and Scripting

how to invoke shell script

hi everybody, i learning unix now only.Can u pls guide me in invoking a shell script.Actually i need to know how to write the command for invoking the shell script.Suppose the shell file name is count , then how i will write the command. thanks (1 Reply)
Discussion started by: gopa_mani
1 Replies

10. UNIX for Dummies Questions & Answers

Bourne Shell Script

Hello, I'm throwing this out there as a novice to the Unix world...I've been working on a project that requires me to ouput (using the echo command) a list of names in a single column format, but the problem is the input is in row format followed by a blank space...If anyone could give me a... (2 Replies)
Discussion started by: dmhonor914
2 Replies
Login or Register to Ask a Question