#!/bin/perl ################################################################################ # auto_cookie.pl # # Purpose: Build a .signature file with a random or specified cookie in it. # # Written by: Kelly Cash on April 22, 2002 # # # # Required files: /usr/local/bin/sig_cookie.pl # # .signature file - Hardcoded location below. # # # # Switches: None. # # # # Args: None. # # # # Serving Suggestion: Put it into .login, .profile, crontab, etc. # # # # Usage examples: auto_cookie.pl # # # # Used with: n/a # # # # Revision history: # # KAC 2002/04/22 Initial implementation # # KAC 2002/05/28 Added grep feature for searching cookie file # # KAC 2002/05/29 Cleaned up option list, user interface (such as it is) # # KAC 2002/06/17 Added "c" cat & "e" edit options # ################################################################################ printf "Enter 'h' for help.\n"; system("cat .signature"); $happy = 0; while ($happy < 1) { printf "\nOption: "; chop($resp = ); if ($resp eq "") { $happy = 1; } else { if ($resp eq "\.") { # Generate a random cookie system("/usr/local/bin/sig_cookie.pl"); printf; system("cat .signature"); } elsif ($resp eq "h") { printf "Options: Keep cookie and exit: \n Random cookie: '.'\n Grep for string: g\n Edit cookie file: e\n Cat cookie file (with pg): c\n Specific record: \n Help: h\n"; } elsif ($resp eq "e") { system("vi /usr/local/bin/cookie.txt"); } elsif ($resp eq "c") { system("pg /usr/local/bin/cookie.txt"); } elsif (substr($resp,0,1) eq "g") { # Grep cookie file for a string $srch = substr($resp,1); system("grep -in $srch /usr/local/bin/cookie.txt"); } else { # Assume the arg is a number and use it. system("/usr/local/bin/sig_cookie.pl -r$resp"); printf; system("cat .signature"); } } }