The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need to invoke a shell script from xml file. sais UNIX for Dummies Questions & Answers 2 05-19-2008 01:01 PM
cd from a Bourne Shell Script - Please Help fawqati Shell Programming and Scripting 10 05-25-2006 03:26 AM
how to invoke shell script gopa_mani Shell Programming and Scripting 1 12-30-2005 10:43 PM
Bourne Shell Script dmhonor914 UNIX for Dummies Questions & Answers 2 12-10-2003 11:25 AM
Bourne shell script need help please ? dezithug UNIX for Advanced & Expert Users 7 10-24-2001 01:59 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-02-2005
Registered User
 

Join Date: May 2005
Posts: 1
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.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-02-2005
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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
Reply With Quote
  #3 (permalink)  
Old 06-04-2006
tayyabq8's Avatar
Moderator
 

Join Date: Nov 2004
Location: Bahrain
Posts: 574
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Bookmarks

Tags
None

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 05:46 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66