jon787
10-19-2001, 11:08 PM
Does anyone have a perl script or something for a randomized signature?
|
Click to See Complete Forum and Search --> : Random Sig jon787 10-19-2001, 11:08 PM Does anyone have a perl script or something for a randomized signature? Gnu/Vince 10-19-2001, 11:11 PM How about a bash script? #!/bin/bash fortune > ~/.signature X_console 10-20-2001, 12:45 AM Have the script run by crontab so it changes every minute. jon787 10-20-2001, 06:00 PM thanks, but one thing How do I make part of the sig stay the same each time without changing the fortune file? [ 20 October 2001: Message edited by: jon787 ] bwkaz 10-20-2001, 06:15 PM Echo the "same" part first, then append the output of fortune, like this: #!/bin/bash echo Put what you want the same in here > ~/.signature fortune >> ~/.signature Or isn't that what you wanted? jon787 10-20-2001, 06:40 PM Okay it looks like it is working. No I wonder if there is a way to get it to happen in this forum? Can I use javascript in my signature on this forum? [ 20 October 2001: Message edited by: jon787 ] Rob 'Feztaa' Park 10-20-2001, 06:54 PM I just have one problem with your script running in cron: that wastes a heck of a lot of CPU cycles, plus if you send more than one email in less than 1 minute, you get duplicated sigs. This is the script I use: #!/usr/bin/python # Python script for random fortune in signature # Import needed modules import fileinput, random, sys, os # Number of arguments passed to script num_args=len(sys.argv) # Don't allow user to try and specify more than one file to use if num_args!=2: print "Specify only one filename to read quotes from!" # If there is only one file specified, and it is accessible, then make the actual sig elif os.access(sys.argv[1], os.R_OK): name="Rob 'Feztaa' Park" email="feztaa@shaw.ca" fortune='' for i in fileinput.input(): fortune=fortune+i fortune=fortune.split("\n%\n") fortune_len=len(fortune) use_fortune=fortune[random.randrange(0,fortune_len)] if (random.randrange(1,10)==1): geek="\n-----BEGIN GEEK CODE BLOCK-----\nVersion: 3.1\nGCS/IT/M/S d(+) s++ :(++:-) a---@>? C+++>++++$ UL++++>$ P+ L+++>$ E---@\nW+++>$$ !N o? !K? w--(- --) O? M-@ V? (!)PS+ (!)PE-- Y+ PGP++@ t(+) !5 X++\nR->-- tv+@ b+ Dl++ D+ G+>++ e->++++ h! r- y>++\n------END GEEK CODE BLOCK------" use_fortune='' else: geek='' # Print everything out all nice and good print "%(name)s\n%(email)s\n--\n%(use_fortune)s%(geek)s" % vars() else: # We can't read the file that the user specified print "Specify a valid filename to read quotes from!" This takes one argument from the commandline, a file that is in the same format as the fortune files (fortunes seperated by % on it's own). It may not be as fast as fortune itself, but you get more control over what fortunes you get in your sig. And then, if you were using mutt, you could add this to your .muttrc: set signature="~/.random_sig/random_sig.py ~/.random_sig/good_sigs|" And you would then get one random sig for every mail you send out. jon787 10-20-2001, 07:28 PM Found an even better way with Mutt I didn't have a .muttrc file so I never even though of this one! Thanks Rob! from ~/.muttrc set signature="/usr/games/fortune ~/custom|" Now my problem is that I also want to add a common line to all my sigs. Is there anyway to o this without adding it to every single fortune? (And without using the cron method!) Rob 'Feztaa' Park 10-20-2001, 11:51 PM Well, you could try: set signature="echo \"common line stuff\";fortune file|" Not tested, though. jon787 10-21-2001, 02:52 PM It works!!! Thanks a bunch. justlinux.com
Copyright Internet.com Inc. All Rights Reserved. |