perlpath.pl 677 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/local/bin/perl
  2. #
  3. # modify the '#!/usr/local/bin/perl'
  4. # line in all scripts that rely on perl.
  5. #
  6. require "find.pl";
  7. $#ARGV == 0 || print STDERR "usage: perlpath newpath (eg /usr/bin)\n";
  8. &find(".");
  9. sub wanted
  10. {
  11. return unless /\.pl$/ || /^[Cc]onfigur/;
  12. open(IN,"<$_") || die "unable to open $dir/$_:$!\n";
  13. @a=<IN>;
  14. close(IN);
  15. if (-d $ARGV[0]) {
  16. $a[0]="#!$ARGV[0]/perl\n";
  17. }
  18. else {
  19. $a[0]="#!$ARGV[0]\n";
  20. }
  21. # Playing it safe...
  22. $new="$_.new";
  23. open(OUT,">$new") || die "unable to open $dir/$new:$!\n";
  24. print OUT @a;
  25. close(OUT);
  26. rename($new,$_) || die "unable to rename $dir/$new:$!\n";
  27. chmod(0755,$_) || die "unable to chmod $dir/$new:$!\n";
  28. }