home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / question / 15393 < prev    next >
Encoding:
Internet Message Format  |  1993-01-10  |  4.1 KB

  1. Xref: sparky comp.unix.questions:15393 comp.unix.aix:13172 comp.unix.shell:5331
  2. Path: sparky!uunet!psinntp!alsys1!yu1.yu.edu!manaster
  3. From: manaster@yu1.yu.edu (Chaim Manaster)
  4. Newsgroups: comp.unix.questions,comp.unix.aix,comp.unix.shell
  5. Subject: Aliases in shell K-shell scripts.
  6. Message-ID: <1277@alsys1.aecom.yu.edu>
  7. Date: 10 Jan 93 21:08:52 GMT
  8. Sender: news@alsys1.aecom.yu.edu
  9. Followup-To: comp.unix.questions
  10. Organization: Yeshiva University
  11. Lines: 102
  12. Nntp-Posting-Host: yu1.yu.edu
  13.  
  14.  
  15.  am having a problem trying to get some aliases that I have defined
  16.  in .kshrc to be recognized by a shell script I use. The script,
  17.  called menu.sh, invokes the alias names but then gets the
  18.  response: alias-name not found.
  19.  
  20.  Do I need to do something special for a script to recognize the
  21.  aliases in the K-shell? 
  22.  
  23.  I am also trying to pass parameters to the alaises and that isn't
  24.  working well either. What is the right way to do that. I am trying
  25.  to use $*, but that isn't working to well. Someone suggested
  26.  putting the $* reference into a function definition, so I tried
  27.  that, --same difference, the parameters are ignored. Also the mv
  28.  commands that follow the rnalias call, report back with usage
  29.  error for mv. I have no idea why. Originally all the mv's where
  30.  cp's with a similar usage error report. Can anyone explain why?
  31.  
  32.  By the way, the rnyutest alias, doesn't get the usage error report
  33.  for "mv" and does accept parameters properly as in:
  34.     rnyutest comp.unix.questions
  35. whereas the rnyu and rncol aliases have both problems??
  36. None of these aliases are recognized froom menu.sh.
  37.  
  38.  I am obviously a neophyte at UNIX.
  39.  
  40.  Thanks in advance for the help.
  41.  
  42.  Henry Manaster
  43.  
  44.  ------------------------The .kshrc file follows----------------
  45.  
  46. # alias ldir="ls -l $* | more"
  47. function ldir {
  48.     ls -l $* | more
  49.     }
  50. # alias adir="ls -al .[a-zA-Z0-9-]* | more"
  51. function adir {
  52.     ls -al .[a-zA-Z0-9-]* | more
  53.     }
  54. function aadir {
  55.     ls -al $* |more
  56.     }
  57. alias elm="elm -z"
  58. alias postyu="export NNTPSERVER=alsys.edu;post"
  59. alias postcol="export NNTPSERVER=sol.edu;post"
  60. function rnalias {
  61.     rn $*
  62.     }
  63. 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'
  64. 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'
  65. alias rnyutest='export NNTPSERVER=alsys.edu;cd;cp .newsrc.yu .newsrc;cp .oldnewsrc.yu .oldnewsrc;cp .rnlast.yu .rnlast;cp .rnsoft.yu .rnsoft;rnalias'
  66.  
  67. ----------------------menu.sh follows here ---------------------
  68.  
  69. #!//bin/ksh
  70. # menu.sh - Easy shell for menu to my liking.
  71. /y/manaster/.kshrc
  72.  
  73. trap "" 2
  74. menu="\t\t\t\tMain Menu
  75. ____________________________________________________________________________
  76. \n\t\t\t1 - rnyu comp.periphs.scsi comp.sys.ibm.pc.hardware
  77. \n\t\t\t2 - rnyu sci.crypt comp.compression .comp.compression.research
  78. \n\t\t\t3 - rnyu comp.text comp.theory.info-retrieval
  79. \n\t\t\t4 - rnyu news.answers
  80. \n\t\t\t5 - rnyu
  81. \n\t\t\t6 - mail
  82. \n\t\t\t7 - elm -z
  83. \n\t\t\t\t X - Exit
  84. ____________________________________________________________________________
  85. \n\t\t\t\tEnter Selection> _\b"
  86. while :
  87. do
  88. echo "$menu\c"
  89. read choice overflow
  90. case $choice in
  91.     1) cd; rnyu comp.periphs.scsi comp.sys.ibm.pc.hardware;;
  92.     2) cd; rnyu sci.crypt comp.compression comp.compression.research;;
  93.     3) cd; rnyu comp.text comp.theory.info-retrieval;;
  94.     4) cd; rnyu news.answers;;
  95.     5) cd; rnyu;;
  96.     6) cd; mail;;
  97.     7) cd; elm -z;;
  98.     [Xx]*) break;;
  99.     *) echo "Sorry, invalid choice. Please try again."
  100.         sleep 2
  101.         continue
  102.         ;;
  103. esac
  104. echo "Finished doing choice #$choice\n\c" ;sleep 2
  105. done
  106.  
  107. -- 
  108. ***************************************************************************
  109.     Henry Manaster          *     EMail: manaster@yu1.yu.edu
  110.     Brooklyn, NY            *
  111.                                 *
  112.     Disclaimer: The above is not necessarily MY opinion nor that 
  113.                 of anyone else :-)  ????!
  114. ****************************************************************************
  115.  
  116.