From: mxcrew@mx2306.gud.siemens.co.at (The MX-Crew)
Newsgroups: comp.unix.questions
Subject: Re: Aliases in shell K-shell scripts.
Date: 12 Jan 93 16:09:42 GMT
Organization: SIEMENS Austria Corp., A-1100 Wien, Gudrunstr. 11
X-Newsreader: Tin 1.1 PL5

Chaim Manaster (manaster@yu1.yu.edu) wrote:
: 
:  am having a problem trying to get some aliases that I have defined
:  in .kshrc to be recognized by a shell script I use. The script,
:  called menu.sh, invokes the alias names but then gets the
:  response: alias-name not found.
: 
:  Do I need to do something special for a script to recognize the
:  aliases in the K-shell? 
: 
:  I am also trying to pass parameters to the alaises and that isn't
:  working well either. What is the right way to do that. I am trying
:  to use $*, but that isn't working to well. Someone suggested
:  putting the $* reference into a function definition, so I tried
:  that, --same difference, the parameters are ignored. Also the mv
:  commands that follow the rnalias call, report back with usage
:  error for mv. I have no idea why. Originally all the mv's where
:  cp's with a similar usage error report. Can anyone explain why?
: 
:  By the way, the rnyutest alias, doesn't get the usage error report
:  for "mv" and does accept parameters properly as in:
: 	rnyutest comp.unix.questions
: whereas the rnyu and rncol aliases have both problems??
: None of these aliases are recognized froom menu.sh.
: 
:  I am obviously a neophyte at UNIX.
: 
:  Thanks in advance for the help.
: 
:  Henry Manaster
: 
:  ------------------------The .kshrc file follows----------------
: 
: # alias ldir="ls -l $* | more"
: function ldir {
: 	ls -l $* | more
: 	}
: # alias adir="ls -al .[a-zA-Z0-9-]* | more"
: function adir {
: 	ls -al .[a-zA-Z0-9-]* | more
: 	}
: function aadir {
: 	ls -al $* |more
: 	}
: alias elm="elm -z"
: alias postyu="export NNTPSERVER=alsys.edu;post"
: alias postcol="export NNTPSERVER=sol.edu;post"
: function rnalias {
: 	rn $*
: 	}
: alias rnyu='export NNTPSERVER=alsys.edu;cd;mv .newsrc.yu .newsrc;mv .oldnewsrc.yu .oldnewsrc;mv .rnlast.yu .rnlast;mv .rnsoft.yu .rnsoft;rnalias;mv newsrc .newsrc.yu;mv .oldnewsrc .oldnewsrc.yu;mv .rnlast .rnlast.yu;mv .rnsoft .rnsoft.yu'
: alias rncol='export NNTPSERVER=sol.edu;cd;mv .newsrc.col .newsrc;mv .oldnewsrc.col .oldnewsrc;mv .rnlast.col .rnlast;mv .rnsoft.col .rnsoft;rnalias;mv .newsrc .newsrc.col;mv .oldnewsrc .oldnewsrc.col;mv .rnlast .rnlast.col;mv .rnsoft .rnsoft.col'
: alias rnyutest='export NNTPSERVER=alsys.edu;cd;cp .newsrc.yu .newsrc;cp .oldnewsrc.yu .oldnewsrc;cp .rnlast.yu .rnlast;cp .rnsoft.yu .rnsoft;rnalias'
: 
: ----------------------menu.sh follows here ---------------------
: 
: #!//bin/ksh
: # menu.sh - Easy shell for menu to my liking.
: /y/manaster/.kshrc
: 
: trap "" 2
: menu="\t\t\t\tMain Menu
: ____________________________________________________________________________
: \n\t\t\t1 - rnyu comp.periphs.scsi comp.sys.ibm.pc.hardware
: \n\t\t\t2 - rnyu sci.crypt comp.compression .comp.compression.research
: \n\t\t\t3 - rnyu comp.text comp.theory.info-retrieval
: \n\t\t\t4 - rnyu news.answers
: \n\t\t\t5 - rnyu
: \n\t\t\t6 - mail
: \n\t\t\t7 - elm -z
: \n\t\t\t\t X - Exit
: ____________________________________________________________________________
: \n\t\t\t\tEnter Selection> _\b"
: while :
: do
: echo "$menu\c"
: read choice overflow
: case $choice in
: 	1) cd; rnyu comp.periphs.scsi comp.sys.ibm.pc.hardware;;
: 	2) cd; rnyu sci.crypt comp.compression comp.compression.research;;
: 	3) cd; rnyu comp.text comp.theory.info-retrieval;;
: 	4) cd; rnyu news.answers;;
: 	5) cd; rnyu;;
: 	6) cd; mail;;
: 	7) cd; elm -z;;
: 	[Xx]*) break;;
: 	*) echo "Sorry, invalid choice. Please try again."
: 		sleep 2
: 		continue
: 		;;
: esac
: echo "Finished doing choice #$choice\n\c" ;sleep 2
: done

try followup:

   grep "alias " <login-startupfile> >/tmp/file.${$} # same to $ENV if set !
   . /tmp/file.${$}
   rm /tmp/file.${$}

--
 +--------------------------------------------+  /-\o /-()  -- -  --   -
 | PEYERL MICHAEL, SIEMENS AG VIENNA          |  \_/ \\/ )  -- -    --
 | E-MAIL: mxcrew at mx2306.gud.siemens.co.at |       |/_\  -- -  --   -
 +--------------------------------------------+        \_/.  .  . . ........
 Honda NX500 Dominator + 588ccm racepiston
Xref: sparky comp.unix.questions:15392 misc.invest:16075