[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cobalt-users] suspending users



Here's two perl scripts:
The first is by Larry Wall, usage is:
Use: [root web]# perl -w  rename.pl s/\.html/\.susp/*.html

The second needs to have the file path changed in it each
time you use it.

############################################################
#!/usr/bin/perl
#
# $Header: rename,v 3.0.1.2 90/08/09 03:17:57 lwall Locked $
#
# $Log: rename,v $
# Revision 3.0.1.2  90/08/09  03:17:57  lwall
# patch19: added man page for relink and rename
#
#
if ($ARGV[0] eq '-i') {
    shift;
    if (open(TTYIN, "</dev/tty") && open(TTYOUT,">/dev/tty")) {
        $inspect++;
        select((select(TTYOUT),$|=1)[0]);
    }
}
($op = shift) || die "Usage: rename [-i] perlexpr [filenames]\n";
if (!@ARGV) {
    @ARGV = <STDIN>;
    chop(@ARGV);
}
for (@ARGV) {
    unless (-e) {
        print STDERR "$0: $_: $!\n";
        $status = 1;
        next;
    }
    $was = $_;
    eval $op;
    die $@ if $@;
    if ($was ne $_) {
        if ($inspect && -e) {
            print TTYOUT "remove $_? ";
            next unless <TTYIN> =~ /^y/i;
        }
        unless (rename($was, $_)) {
            print STDERR "$0: can't rename $was to $_: $!\n";
            $status = 1;
        }
    }
}
exit $status;
############################################################################
##

Number 2:

#!/usr/bin/perl
#
###################
# Renamer
# Written by Mike Wheeler 6/24/96
# Copyright 1996, All rights reserved
#
# This script is for changing the file extension on all the files (with
# the original file extension) in a directory. For example to make all
# your .html files into .shtml files or .html files into .htm files.
##################

$file_dir = "/home/sites/deleted/web/";
# This is the directory where all the files to be renamed are.

$ext1 = ".html";
# This is the original file extension (begiining with a period)

$ext2 = ".susp";
# This is the new file extension (beginning with a period)

# That's it! Be sure to chmod the script to 755 and run it from the
# Unix shell (rather than your browser).
###################
opendir(FILES,"$file_dir");
@allfiles = grep(!/^\.\.?$/,readdir(FILES));
closedir(FILES);
foreach $file(@allfiles){
   $newfile = $file;
   $newfile=~ s/$ext1/$ext2/g;
   rename("$file_dir/$file","$file_dir/$newfile");
}
exit;
###################################################################







-----Original Message-----
From: cobalt-users-admin@xxxxxxxxxxxxxxx
[mailto:cobalt-users-admin@xxxxxxxxxxxxxxx]On Behalf Of Dom Latter
Sent: Thursday, February 03, 2000 7:35 AM
To: cobalt-users@xxxxxxxxxxxxxxx
Subject: Re: [cobalt-users] suspending users


Jeff Lasman wrote:
>
> To disable the website, mv his index.html file to index.html.suspended,
and
> create a new index.html file with the "This user is suspended" text in
> it.  Then when you reinstate, just delete the index.html file and mv
> index.html.suspended back to index.html.

Tho' anybody that knows the URL of the other pages will still
be able to get at them.  Can a shell guru here provide us with
a line that will do a mass move of all files in a directory from
filename.html to filename.html.suspend?


_______________________________________________
cobalt-users mailing list
cobalt-users@xxxxxxxxxxxxxxx
http://list.cobalt.com/mailman/listinfo/cobalt-users