The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 11:43 PM
Bourne Shell Script dmhonor914 UNIX for Dummies Questions & Answers 2 12-10-2003 12:25 PM
Bourne shell script need help please ? dezithug UNIX for Advanced & Expert Users 7 10-24-2001 01:59 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-02-2005
techshots techshots is offline
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.
  #2 (permalink)  
Old 05-02-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
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
  #3 (permalink)  
Old 06-04-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 578
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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