Settings

The page will reload to apply your changes.
Theme

ASCII Art Font

ASCII Art Menu

Original Usenet thread from alt.ascii-art, started 15 Dec 1994.
 _   _                     _        _             _     _           
| | | |___  ___ _ __   ___| |_     / \   _ __ ___| |__ (_)_   _____ 
| | | / __|/ _ \ '_ \ / _ \ __|   / _ \ | '__/ __| '_ \| \ \ / / _ \
| |_| \__ \  __/ | | |  __/ |_   / ___ \| | | (__| | | | |\ V /  __/
 \___/|___/\___|_| |_|\___|\__| /_/   \_\_|  \___|_| |_|_| \_/ \___|
Anyway to randomize sig files?

Anyway to randomize sig files?

alt.ascii-art · 10 messages · 15 Dec 1994 - 19 Dec 1994
Hi everybody,

        Can someone tell me if there is a way to randomize sig files?
        IF so, using what?
        Thanks.

On Thu, 15 Dec 94 08:15:42 GMT, 
p  <     p...@outpost.pl.my> wrote:

>Hi everybody,
>
>        Can someone tell me if there is a way to randomize sig files?
>        IF so, using what?
>        Thanks.
>
>

With what program?

Daniel Claflin <cla...@gwis2.circ.gwu.edu> ASCII art 15 Dec 1994 16:05 · permalink · report
Terry :-) str...@student.msu.edu said on <Thu, 15 Dec 94 05:27:19 EST>,
in alt.ascii-art: 

*] On Thu, 15 Dec 94 08:15:42 GMT, 
*] p  <     p...@outpost.pl.my> wrote:

*] >Hi everybody,
*] >
*] >        Can someone tell me if there is a way to randomize sig files?
*] >        IF so, using what?
*] >        Thanks.
*] >
*] >

*] With what program?


How about with Pine? Any way possible?

Thanks,

Dan (+:

--


                                                             
   ________________________________________________________
  /   \                                                    \   
 |  \~~|            THIS MESSAGE BROUGHT TO YOU BY:         |    
  \_/__|                   Daniel L. Claflin                |   
  /~\~~|             <cla...@gwis2.circ.gwu.edu>           |   
 |\_/__|                                                    |   
  \___/____________________________________________________/    
  

In article <3cppfl$mc...@cronkite.seas.gwu.edu>,
	[deleted talk about randomizing sigs.]
>
>
>How about with Pine? Any way possible?

	As you know Pine uses the file .signature (sp?) as its
	default signature. I think you may have to set the option to"on" but
	you get the point.

	Now, the key then is to get the file .signature to change.
	Let say you keep your sigs like this (by filename)
	.sig0 .sig1 .sig2 and so on.
	Then a script would simply have to
	  1) rm .signature
	  2) generate a random number
	  3) use that number to pick one of the .sig# files.

	This script could be run by a cron job
	or you could execute it by calling it in your
	.login file. Of cousre the permission on the
	script would have to be 700 or 755.. ect.

	Type "man sh" for some insights.

	For those who dont know much about 
	UNIX this may sound like a bunch of jibberish.

	In that case perhaps someone who has such a script
	would be willing to share it..

	Dan, if you know the programming language "C"
	I would be willing to send you the code that
	changes the assci image in the motd every day.

	If you know "C" you could easily modify to 
	generate a random .signature every time you
	executed the program.

	ltr-p-

>Dan (+:

Marcus Liang <mar...@outpost.pl.my> ASCII art 17 Dec 1994 17:10 · permalink · report
In article <345...@student.msu.edu> str...@student.msu.edu writes:
>>        Can someone tell me if there is a way to randomize sig files?
>>        IF so, using what?
>>        Thanks.

>With what program?

Yeah. That's exactly what I wanted to know. :-)
I'm using UUPC and I know there's a way to randomize taglines but
it's sorta tedious also.
Anybody knows any external programs that does randomizing (sigs or
tags) that works with UUPC?

Any input would be appreciated. :-) Thanx.

--
____________________________________________________________________________
  |\/|  /| |) /` | | (`  |        Marcus Liang % Selangor % Malaysia
__|  | /-| |\ \, |_| _)__|_____Internet_E-Mail_%_<mar...@outpost.pl.my>_____

Eli the bearded <bgr...@ic.sunysb.edu> ASCII art 17 Dec 1994 17:13 · permalink · report
Note cross posting.

In article <3csckl$br...@lastactionhero.rs.itd.umich.edu>,
kna...@cochrane.bus.umich.edu (Kent Stefl Nassen) writes:
>>*] >        Can someone tell me if there is a way to randomize sig files?
>Here is a perl script I grabbed from somewhere.  It was originally set
>up to put random one-line quotes in your .sig, but I modified it to
>just randomize a group of .sig files.  Very simple.  I use it with pine
>by aliasing pine to 'randsig; pine'.  Then, whenever pine is run, you
>will get a random sig.  You can use the same aliasing trick for other
>programs, assuming your shell allows aliases.

	#!/location/of/perl
	
	$home = "/your/home/directory";
	srand(time|$$);
	@files = <$home/sigs/*>;
	$this = $files[rand(@files)];
	
	`cp $this $home/.signature`;
	
Anybody either have or can quickly modify this to
be more friendly to the inode-imparied? My site has the
absurd idea that I should only have 800 files. At this
moment I am about 100 away from the limit. Lots of extra
files will not help. Putting all the files in a cpio or
ar archive would be great. Creating a new file format for
this is fine as well.

Elijah
------
has yet to learn perl

Daniel Claflin <cla...@gwis2.circ.gwu.edu> ASCII art 17 Dec 1994 22:02 · permalink · report
Kent Stefl Nassen kna...@cochrane.bus.umich.edu said on <16 Dec 1994
15:44:21 GMT>, in alt.ascii-art: 

I would like to thank you for posting this, but I have a slight problem 
with it. *sigh* It keeps choosing the same file every time.  Whenever I 
run this, it always chooses the first file within the directory.... )+:

*] #!/location/of/perl
*]  
*] $home = "/your/home/directory";
*] srand(time|$$);
*] @files = <$home/sigs/*>;
		       ^^^^

Is there something that I could change this to so that it will choose a 
truely random file from it? Or will I need to use a different program to 
do it?.....(I'm just a beginner when it comes to coding and programing... 
so I'm still a bit ignorate here...)


*] $this = $files[rand(@files)];
*]  
*] `cp $this $home/.signature`;


Any suggestions would be much appreciated...

Thanks,
Dan (+:

--
   ________________________________________________________
  /   \                                                    \   
 |  \~~|            THIS MESSAGE BROUGHT TO YOU BY:         |    
  \_/__|                   Daniel L. Claflin                |   
  /~\~~|             <cla...@gwis2.circ.gwu.edu>           |   
 |\_/__|                                                    |   
  \___/____________________________________________________/    

Randal L. Schwartz <mer...@stonehenge.com> ASCII art 18 Dec 1994 00:15 · permalink · report
>>>>> "Eli" == Eli the bearded <bgr...@ic.sunysb.edu> writes:

Eli> Note cross posting.
Eli> In article <3csckl$br...@lastactionhero.rs.itd.umich.edu>,
Eli> kna...@cochrane.bus.umich.edu (Kent Stefl Nassen) writes:
>>> *] >        Can someone tell me if there is a way to randomize sig files?
>> Here is a perl script I grabbed from somewhere.  It was originally set
>> up to put random one-line quotes in your .sig, but I modified it to
>> just randomize a group of .sig files.  Very simple.  I use it with pine
>> by aliasing pine to 'randsig; pine'.  Then, whenever pine is run, you
>> will get a random sig.  You can use the same aliasing trick for other
>> programs, assuming your shell allows aliases.

Eli> 	#!/location/of/perl
	
Eli> 	$home = "/your/home/directory";
Eli> 	srand(time|$$);
Eli> 	@files = <$home/sigs/*>;
Eli> 	$this = $files[rand(@files)];
	
Eli> 	`cp $this $home/.signature`;
	
Eli> Anybody either have or can quickly modify this to
Eli> be more friendly to the inode-imparied? My site has the
Eli> absurd idea that I should only have 800 files. At this
Eli> moment I am about 100 away from the limit. Lots of extra
Eli> files will not help. Putting all the files in a cpio or
Eli> ar archive would be great. Creating a new file format for
Eli> this is fine as well.

Well, put them all in the perl program then:

	#!/usr/bin/perl
	srand(time ^ $$); # not |, which loses information
	$/ = "\n%%\n";
	@sigs = <DATA>;
	open(SIG, ">.signature");
	print SIG $sigs[rand(@sigs)], "\n";
	__END__
	Here's a sig
	and it can have multiple lines
	%%
	Here's the second sig
	and it too
	can have multiple lines
	%%
	Here's another sig that has %% somewhere in it.
	%%
	And here's another sig.  Really!

There.  It's just one file, with the data in the program.  Perl is
Your Friend.

print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <mer...@stonehenge.com> Snail: (Call) PGP-Key: (finger mer...@ora.com)
Phrase: "Welcome to Portland, Oregon ... home of the California Raisins!"

Daniel Claflin <cla...@gwis2.circ.gwu.edu> ASCII art 18 Dec 1994 03:59 · permalink · report
I'm still having problems in that the randomizing isn't working for me.
It always seems to choose the first one.. I've tried to run the two
programs that I've found on this group and both of them have not
successfully randomized it at all.. )+:

Maybe I'm doing something wrong?...

I know it really doesn't matter that much, it's just a neat little gadget
anyways...so I just wish to really thank all the people out there trying
to help and all... especially since they are much more talented than
myself...



Randal L. Schwartz mer...@stonehenge.com said on <18 Dec 1994 00:15:28
GMT>, in alt.ascii-art:


*] Well, put them all in the perl program then:

*] 	#!/usr/bin/perl
*] 	srand(time ^ $$); # not |, which loses information
*] 	$/ = "\n%%\n";
*] 	@sigs = <DATA>;
*] 	open(SIG, ">.signature");
*] 	print SIG $sigs[rand(@sigs)], "\n";
*] 	__END__
*] 	Here's a sig
*] 	and it can have multiple lines
*] 	%%
*] 	Here's the second sig
*] 	and it too
*] 	can have multiple lines
*] 	%%
*] 	Here's another sig that has %% somewhere in it.
*] 	%%
*] 	And here's another sig.  Really!

*] There.  It's just one file, with the data in the program.  Perl is
*] Your Friend.           				      ^^^^^^^^
^^^^^^^^^^^^^^^^
I sure hope so... atleast it seems to be... (+:

Thanks again...
Dan (+:

--
   ________________________________________________________
  /   \                                                    \
 |  \~~|            THIS MESSAGE BROUGHT TO YOU BY:         |
  \_/__|                   Daniel L. Claflin                |
  /~\~~|             <cla...@gwis2.circ.gwu.edu>           |
 |\_/__|                                                    |

Tom Christiansen <tch...@mox.perl.com> ASCII art 19 Dec 1994 15:16 · permalink · report
#!/usr/bin/perl
#
# sigrand -- supply random fortunes for .signature file
# Tom Christiansen -- tch...@perl.com

################################################################
# begin configuration section

$MKNOD = "/etc/mknod";

$SIG{'PIPE'} = 'IGNORE';

&gethome;

# for rec/humor/funny instead of rec.humor.funny
$NG_IS_DIR 	= 1; 	

$FULLNAME 	= "$HOME/.fullname";
$FIFO 		= "$HOME/.signature";
$ART 		= "$HOME/.article";
$NEWS 		= "$HOME/News";
$SIGS 		= "$NEWS/SIGNATURES";
$SEMA		= "$HOME/.sigrandpid";
$GLOBRAND	= 1/4;	# chance to use global sigs anyway

# end configuration section -- HOME and FORTUNE get autoconf'd
################################################################

&setup;

&justme;

#fork && exit; 	# be a daemon

open (SEMA, ">$SEMA") || die "can't write $SEMA: $!";
print SEMA "$$\n";
close SEMA || die "can't close $SEMA: $!";

MAIN: while (1) {
    open (FIFO, "> $FIFO") || die "can't write $FIFO: $!";
    &load_sigs;
    $sig = $sig[rand @sig];
    print FIFO $name, "\n" x (3 - ($sig =~ tr/\n//)), $sig;
    close FIFO;
    sleep 2; # to avoid dup sigs
}
die "NOT REACHED";

################################################################

sub setup {
    if (-e $FULLNAME) {
	$name = `cat $FULLNAME`;
	die "$FULLNAME should contain only 1 line, aborting"
	    if $name =~ tr/\n// > 1;
    } else {
	chop($host = `hostname`);
	($host) = gethostbyname($host) unless $host =~ /\./;
	$user = $ENV{USER} || $ENV{LOGNAME} || $pw[0] || die "intruder alert";
	($name = $pw[6]) =~ s/,.*//;
	$name =~ s/&/\u\L$user/g; # can't believe some folks still do this
	$name = "\t$name\t$user\@$host\n";
    }


    &check_fortunes if !-e $SIGS;

    unless (-p $FIFO) {
	if (!-e _) {
	    system("$MKNOD $FIFO p") && die "can't mknod $FIFO";
	    warn "created $FIFO as a named pipe\n";
	} else {
	    die "$0: won't overwrite file .signature\n";
	}
    }


    srand(time|$$);
}

sub load_sigs {
    local($sigfile) = &ng;
    if (!-e $sigfile) {
	@sig = (&fortune);
	return;
    }
    open (SIGS,$sigfile) || die "can't open $sigfile";
    local($/) = "%%\n";
    undef @sig;
    while (<SIGS>) {
	s!$/$!!o;
	push(@sig,$_);
    }
    close SIGS;
}

sub ng {
     (rand(1.0) > ($GLOBRAND) && open ART) || return $SIGS;
     local($/) = '';
     $_ = <ART>;
     ($ng) = /Newsgroups:\s*([^,\s]*)/;
     $ng =~ s!\.!/!g if $NG_IS_DIR; 	# if rn -/,  or SAVEDIR=%p/%c
     $ng = "$NEWS/$ng/SIGNATURES";
     -f $ng ? $ng : $SIGS;
}

sub fortune {
   local($_, $tries);
   do {
       $_ = `$FORTUNE -s`;
   } until tr/\n// < 4 || $tries++ > 20;
   local($*) = 1;
   s/^/ /g;
   $_ || " SIGRAND: deliver random signals to all processes.\n";
}

sub check_fortunes {
    return if $FORTUNE;
    foreach $dir (split(/:/, $ENV{PATH}), '/usr/games') {
	return if -x ($FORTUNE = "$dir/fortune");
    }
    die "Need either $SIGS or a fortune program, bailing out";
}

sub gethome {
    @pw = getpwuid($<);
    $HOME = $ENV{HOME} || $ENV{LOGDIR} || $pw[7]
		       || die "no home directory for user $<";
}

# "There can be only one."  --the Highlander
sub justme {
    if (open SEMA) {
	chop($pid = <SEMA>);
	kill(0, $pid) && die "$0 already running (pid $pid)\n";
	#warn "COOL: no $pid: $!";
	close SEMA;
    }
}
--
Tom Christiansen      Perl Consultant, Gamer, Hiker      tch...@mox.perl.com

    stab_val(stab)->str_nok = 1;    /* what a wonderful hack! */
        --Larry Wall in stab.c from the perl source code

About this thread. These messages were posted publicly to the newsgroup alt.ascii-art in 1994 and are mirrored here unchanged as part of the Historic Archives – only email addresses are masked. The artwork and text belong to their original authors: if you copy a piece, keep the artist's initials or signature intact and credit them where you can. Are you one of the authors? Contact us to get your posts attributed, connected to your artist profile, or removed.

Report this message

Help us keep the archive clean and accurate. Reports are reviewed by a person – nothing is changed automatically.

Help classify this post