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

  1. Path: sparky!uunet!olivea!spool.mu.edu!howland.reston.ans.net!paladin.american.edu!news.univie.ac.at!hp4at!siemens.co.at!mxcrew
  2. From: mxcrew@mx2306.gud.siemens.co.at (The MX-Crew)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: Aliases in shell K-shell scripts.
  5. Message-ID: <1993Jan12.160942.18736@siemens.co.at>
  6. Date: 12 Jan 93 16:09:42 GMT
  7. References: <1277@alsys1.aecom.yu.edu>
  8. Sender: news@siemens.co.at (Newssoftware)
  9. Organization: SIEMENS Austria Corp., A-1100 Wien, Gudrunstr. 11
  10. Lines: 106
  11. Nntp-Posting-Host: mx2306.gud.siemens-austria
  12. X-Newsreader: Tin 1.1 PL5
  13.  
  14. Chaim Manaster (manaster@yu1.yu.edu) wrote:
  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. :  Do I need to do something special for a script to recognize the
  20. :  aliases in the K-shell? 
  21. :  I am also trying to pass parameters to the alaises and that isn't
  22. :  working well either. What is the right way to do that. I am trying
  23. :  to use $*, but that isn't working to well. Someone suggested
  24. :  putting the $* reference into a function definition, so I tried
  25. :  that, --same difference, the parameters are ignored. Also the mv
  26. :  commands that follow the rnalias call, report back with usage
  27. :  error for mv. I have no idea why. Originally all the mv's where
  28. :  cp's with a similar usage error report. Can anyone explain why?
  29. :  By the way, the rnyutest alias, doesn't get the usage error report
  30. :  for "mv" and does accept parameters properly as in:
  31. :     rnyutest comp.unix.questions
  32. : whereas the rnyu and rncol aliases have both problems??
  33. : None of these aliases are recognized froom menu.sh.
  34. :  I am obviously a neophyte at UNIX.
  35. :  Thanks in advance for the help.
  36. :  Henry Manaster
  37. :  ------------------------The .kshrc file follows----------------
  38. : # alias ldir="ls -l $* | more"
  39. : function ldir {
  40. :     ls -l $* | more
  41. :     }
  42. : # alias adir="ls -al .[a-zA-Z0-9-]* | more"
  43. : function adir {
  44. :     ls -al .[a-zA-Z0-9-]* | more
  45. :     }
  46. : function aadir {
  47. :     ls -al $* |more
  48. :     }
  49. : alias elm="elm -z"
  50. : alias postyu="export NNTPSERVER=alsys.edu;post"
  51. : alias postcol="export NNTPSERVER=sol.edu;post"
  52. : function rnalias {
  53. :     rn $*
  54. :     }
  55. : 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'
  56. : 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'
  57. : alias rnyutest='export NNTPSERVER=alsys.edu;cd;cp .newsrc.yu .newsrc;cp .oldnewsrc.yu .oldnewsrc;cp .rnlast.yu .rnlast;cp .rnsoft.yu .rnsoft;rnalias'
  58. : ----------------------menu.sh follows here ---------------------
  59. : #!//bin/ksh
  60. : # menu.sh - Easy shell for menu to my liking.
  61. : /y/manaster/.kshrc
  62. : trap "" 2
  63. : menu="\t\t\t\tMain Menu
  64. : ____________________________________________________________________________
  65. : \n\t\t\t1 - rnyu comp.periphs.scsi comp.sys.ibm.pc.hardware
  66. : \n\t\t\t2 - rnyu sci.crypt comp.compression .comp.compression.research
  67. : \n\t\t\t3 - rnyu comp.text comp.theory.info-retrieval
  68. : \n\t\t\t4 - rnyu news.answers
  69. : \n\t\t\t5 - rnyu
  70. : \n\t\t\t6 - mail
  71. : \n\t\t\t7 - elm -z
  72. : \n\t\t\t\t X - Exit
  73. : ____________________________________________________________________________
  74. : \n\t\t\t\tEnter Selection> _\b"
  75. : while :
  76. : do
  77. : echo "$menu\c"
  78. : read choice overflow
  79. : case $choice in
  80. :     1) cd; rnyu comp.periphs.scsi comp.sys.ibm.pc.hardware;;
  81. :     2) cd; rnyu sci.crypt comp.compression comp.compression.research;;
  82. :     3) cd; rnyu comp.text comp.theory.info-retrieval;;
  83. :     4) cd; rnyu news.answers;;
  84. :     5) cd; rnyu;;
  85. :     6) cd; mail;;
  86. :     7) cd; elm -z;;
  87. :     [Xx]*) break;;
  88. :     *) echo "Sorry, invalid choice. Please try again."
  89. :         sleep 2
  90. :         continue
  91. :         ;;
  92. : esac
  93. : echo "Finished doing choice #$choice\n\c" ;sleep 2
  94. : done
  95.  
  96. try followup:
  97.  
  98.    grep "alias " <login-startupfile> >/tmp/file.${$} # same to $ENV if set !
  99.    . /tmp/file.${$}
  100.    rm /tmp/file.${$}
  101.  
  102. --
  103.  +--------------------------------------------+  /-\o /-()  -- -  --   -
  104.  | PEYERL MICHAEL, SIEMENS AG VIENNA          |  \_/ \\/ )  -- -    --
  105.  | E-MAIL: mxcrew at mx2306.gud.siemens.co.at |       |/_\  -- -  --   -
  106.  +--------------------------------------------+        \_/.  .  . . ........
  107.  Honda NX500 Dominator + 588ccm racepiston
  108.