home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1443 < prev    next >
Internet Message Format  |  1990-12-28  |  2KB

  1. From: shipley@riki.berkeley.edu (Pete Shipley)
  2. Newsgroups: alt.sources
  3. Subject: Testpath: a path testing program.
  4. Message-ID: <1990Jun10.225128.10821@agate.berkeley.edu>
  5. Date: 10 Jun 90 22:51:28 GMT
  6.  
  7.  
  8. Testpath checks for the existance of each item in an user's path
  9. and reports bad entries.
  10.  
  11. #! /bin/sh
  12. mkdir Testpath
  13. cd Testpath
  14. #! /bin/sh
  15. echo x - testpath
  16. cat >testpath <<'!E!O!F!'
  17. #! /bin/csh 
  18.  
  19. set spath=""
  20. set ppath=""
  21. unset vflag pflag
  22.  
  23. top:
  24. if ($#argv > 0) then
  25.     switch ($1)
  26.  
  27.     case -v:
  28.     set vflag=1
  29.     shift
  30.     goto top
  31.  
  32.     case -p:
  33.     set pflag=1
  34.     shift
  35.     goto top
  36.  
  37.     default:
  38.     set spath="$spath $1"
  39.     shift
  40.     goto top
  41.     endsw
  42. endif
  43.  
  44. if ( "$spath" == "" ) then
  45.     set spath="$path"
  46. endif
  47.  
  48. foreach i ($spath) 
  49.  
  50.     if ( ! -d $i ) then
  51.     if (! $?pflag ) then
  52.         echo "Bad path component:" $i
  53.     endif
  54.     else
  55.     set ppath = "$ppath $i"
  56.     if ( $?vflag ) then
  57.         ls -lLdg $i
  58.     endif
  59.     endif
  60. end
  61.  
  62. if ( $?pflag ) then
  63.     echo $ppath
  64. endif
  65. !E!O!F!
  66. #! /bin/sh
  67. echo x - testpath.man
  68. cat >testpath.man <<'!E!O!F!'
  69. .TH testpath 1 local
  70. .SH NAME
  71. testpath - test users path for valid entries
  72. .SH SYNOPSIS
  73. testpath [-v] [-p] [path] 
  74. .SH DESCRIPTION
  75. Testpath checks for the existance of each item in an user's path
  76. and reports bad entries.
  77. .SH OPTIONS
  78. .TP
  79. .B \-v
  80. list each path entry to inspect permissions.
  81. .TP
  82. .B \-p
  83. only print out valid path segments,
  84. bad entries in user's path are not reported.
  85. This is useful for checking a path before setting it.
  86. For example:
  87. .in +0.5i
  88. set path = `testpath -p /bin /usr/new /usr/bin /usr/ucb /usr/local/bin`
  89. .in -0.5i
  90. .LP
  91. If no path is given as an argument, testpath uses the path from
  92. the user's .cshrc.
  93. .SH FILES
  94. $HOME/.cshrc
  95. .SH SEE ALSO
  96. csh(1), ls(1)
  97. .SH DIAGNOSTICS
  98. Few, mostly from the shell.
  99. .SH AUTHOR
  100. Peter Shipley
  101. .SH BUGS
  102. written in csh.
  103. .\" END OF TEXT
  104. !E!O!F!
  105. cd ..
  106. Pete Shipley: 
  107. email: shipley@berkeley.edu        Flames:  cimarron@postgres.berkeley.edu 
  108.        uunet!lurnix!shipley or ucbvax!shipley or pyramid!hippo!{ root peter }
  109. Spelling corections: /dev/null                    Quote: "Anger is an energy"
  110.