Discussion:
? Howto use some output into a Signature ?
(too old to reply)
Joao-Philippe
2007-03-21 02:22:34 UTC
Permalink
Hi Community

Trying to grab another not-that-important echelon going up the learning curve:

I noticed Boyan to have ever-changing sigs based, I imagine, on the output of
something like "fortune".

How one does achieve this ?

Cheers - a link to some HowTo will do.

Jean-Philippe
--
Linux openSUSE 10.2 kernel 2.6.18
Joao-Philippe
2007-03-21 03:57:27 UTC
Permalink
"Settings->Configure KMail->Identities->Modify...->Signature->Obtain
signature text from" should be set to "Output from command".
Workin' - I just filled the "output frrm Command" box with "fortune" & now I
can display silly quotes to unfortunate readers.

Thanks

Jean-Philippe
--
Just because you're paranoid doesn't mean they AREN'T after you.
Boyan Tabakov
2007-03-21 07:10:28 UTC
Permalink
Post by Joao-Philippe
"Settings->Configure KMail->Identities->Modify...->Signature->Obtain
signature text from" should be set to "Output from command".
Workin' - I just filled the "output frrm Command" box with "fortune" & now
I can display silly quotes to unfortunate readers.
Thanks
Jean-Philippe
That great - someone noticed my signatures! :) Another thing you can do is
write a simple shell/other script that gives more control on the output. In
my case this is a perl script that prints some extra stuff besides the
fortune output (and furtune uses my custom made Nightwish quotes).
--
Blade hails you...

Ever felt away with me
Just once that all I need
Entwined in finding you one day
--Nightwish
Paul Cartwright
2007-03-21 10:27:53 UTC
Permalink
Post by Boyan Tabakov
That great - someone noticed my signatures! :) Another thing you can do is
write a simple shell/other script that gives more control on the output. In
my case this is a perl script that prints some extra stuff besides the
fortune output (and furtune uses my custom made Nightwish quotes).
--
Blade hails you...
Ever felt away with me
Just once that all I need
Entwined in finding you one day
                    --Nightwish
care to share?? I have a 13 meg file of "random" sayings... that I USED to use
in a windows email program.
--
Paul Cartwright
Registered Linux user # 367800
Ubuntu User number is # 12459
Boyan Tabakov
2007-03-21 14:26:32 UTC
Permalink
Post by Paul Cartwright
Post by Boyan Tabakov
That great - someone noticed my signatures! :) Another thing you can do
is write a simple shell/other script that gives more control on the
output. In my case this is a perl script that prints some extra stuff
besides the fortune output (and furtune uses my custom made Nightwish
quotes).
--
Blade hails you...
Ever felt away with me
Just once that all I need
Entwined in finding you one day
                    --Nightwish
care to share?? I have a 13 meg file of "random" sayings... that I USED to
use in a windows email program.
Sure... Attached are the fortune file, along with the .dat string index file
(copy those to fortune folder, which on SuSE is /usr/share/fortune). The file
signature is my perl script that takes one argument - blade, formal or
cnsys - and prints the corresponding signature. It is nothing special.
--
Blade hails you...

Today I killed, he was just a boy
Eight before him, I knew them all
In the fields a dying oath:
I'd kill them all to save my own
--Nightwish
Jean-Philippe
2007-03-22 00:12:19 UTC
Permalink
Post by Boyan Tabakov
Sure... Attached are the fortune file, along with the .dat string index
file (copy those to fortune folder, which on SuSE is /usr/share/fortune).
The file signature is my perl script that takes one argument - blade,
formal or cnsys - and prints the corresponding signature. It is nothing
special.
Hi Blade. Thanks for the Peal lines.

How do you generate the .dat file (from the text file I guess) To have "your"
quotes ?
--
Ben (Obi-Wan) Kenobi:
Use the Force, Luke!
Boyan Tabakov
2007-03-22 07:16:13 UTC
Permalink
Post by Jean-Philippe
Post by Boyan Tabakov
Sure... Attached are the fortune file, along with the .dat string index
file (copy those to fortune folder, which on SuSE is /usr/share/fortune).
The file signature is my perl script that takes one argument - blade,
formal or cnsys - and prints the corresponding signature. It is nothing
special.
Hi Blade. Thanks for the Peal lines.
How do you generate the .dat file (from the text file I guess) To have
"your" quotes ?
The command you need is strfile. See the man page for details on the usage.
--
Blade hails you...

None of you understand
And it doesn't matter
To a broken marionette like me
%
--Nightwish
Jean-Philippe
2007-03-22 11:58:11 UTC
Permalink
Workin'

needed to chmod the file, not forgetting to add the extra command needed by
your script !
--
Cheers...

Emperor Palpatine:
Everything that has transpired has done so according
to my design.
--starwars fortune output--
Boyan Tabakov
2007-03-22 12:26:41 UTC
Permalink
Post by Joao-Philippe
Workin'
needed to chmod the file, not forgetting to add the extra command needed by
your script !
chmod was self explanatory I think:) but what command was missing?

Nice that you have it working the way you want...
--
Blade hails you...

I wish I had an angel
For one moment of love
--Nightwish
Jean-Philippe
2007-03-23 03:36:04 UTC
Permalink
Post by Boyan Tabakov
Post by Joao-Philippe
Workin'
needed to chmod the file, not forgetting to add the extra command needed
by your script !
chmod was self explanatory I think:) but what command was missing?
Nice that you have it working the way you want...
Let's do it the long way, so others, like me could learn from it (if
interested at all)

Your 'signature' script originally got three parameters: "blade | formal |
cnsys", that returns different sigs - where I would expect "perltabakov"
script to return a sig (or an output in the console), it's
actually "perltabakov blade" that would do what's defined in the "blade"
section of your scripts:

Let's have a look at my perltabakov script:

[code - simplified & commented]
#!/usr/bin/perl
# 'perltabakov' signature script
# From Boyan Tabakov, Mod'ed & commented by J.-Ph.
# useage: 'perltabakov fortune' or 'perltabakov formal'
# save it as 'perltabakov' in $home/bin
# try it in a terminal for accurate foolproofing, after running
# 'sudo chmod 777 /home/_username_/bin/perltabakov'

# first given parameter, will do with 'perltabakov fortune' command:
if ($ARGV[0] eq 'fortune')
{
# some fixed content:
print " \n";
print "Cheers...\n\n";
# fortune output variable content
open IN, "-|", "fortune starwars" or die "Could not read fortune!\n\n";
# you are sure free to choose your fortune file here
# defining "fortune" alone would randomly choose between all fortune files.
# Fortune Files are usually in /usr/share/fortune
# Edit this if you do not have "starwars" !
@lines = <IN> or die "Could not read input!\n";
chomp @lines;
($l) = sort {$b <=> $a} map {length} @lines;
# back to fixed content:
print " ";
$n = "--starwars fortune output--";
# Or anything you'd like...
print (join "\n", @lines);
printf "\n%*s\n", $l, $n;
}
#end of 'fortune' part with variable content

# second parameter, will do with 'fortune formal' command
elsif ($ARGV[0] eq 'formal')
# just print a string of text:
{
print "Jean-Philippe Monteiro\n";
}
# That's it, you have a more 'formal' signature !

# Will print a hint if improper command is given in a console:
else
{
print STDERR "Usage signature [fortune|formal]\n";
}
# end of the thing. You'd have to call it "perltabakov" tough :)

# The command is to be inserted in a console or in
# Kontact > tools > configure Kmail > Identities Tab > edit > signatures
# Select "output from command" & insert the said command.
[end of code]

Thanks to the last line:
else {print STDERR "Usage signature [fortune|formal]\n";}

running the script in a console showed the need to define the extra parameter,
-command "perltabakov jph" returns the star wars fortune with extra fixed
content, in kmail & console
-Command "perltabakov formal" returns "jean philippe monteiro"

Running in the console at first showed the need to chmod it - I wasn't
expecting that, it doesn't make sense to me to change the permissions to run
a script that was build, saved & launched under the same user !

Enough for now, I guess this list is _not_ the Perl-Clasroom-for-Dummies :)

Thanks again, I will play around a bit more on it.

Jean-Philippe

Attached is my script, in need of edition if you do not have starwars (!)
http://freshmeat.net/browse/895/
--
Cheers...

Han Solo:
You said you wanted to be around when I made a mistake,
well, this could be it, sweetheart.
Princess Leia:
I take it back.
--starwars fortune output--
Boyan Tabakov
2007-03-23 07:27:02 UTC
Permalink
Post by Jean-Philippe
Running in the console at first showed the need to chmod it - I wasn't
expecting that, it doesn't make sense to me to change the permissions to
run a script that was build, saved & launched under the same user !
You always have to allow your scripts to be executed as commands by changing
their permissions (the x one). Otherwise you have to launch your script with
an interpreter command - e.g. "perl myscript". Now you don't need the entire
777 permission, because obviously you don't want someone else to modify your
script. (On home computers this doesn't matter that much, but again it is not
a good practice). All you need is 700 or the more commonly used 755.

Anyway - for someone who said to be new to perl, you did a great job making
the script work for you!
--
Blade hails you...

Our souls will join again the wild
--Nightwish
Joao-Philippe
2007-03-21 10:36:15 UTC
Permalink
Post by Boyan Tabakov
That great - someone noticed my signatures! :) Another thing you can do is
write a simple shell/other script that gives more control on the output. In
my case this is a perl script that prints some extra stuff besides the
fortune output (and furtune uses my custom made Nightwish quotes).
On my Slack box, I got a "hitchhiker" fortune, but it isn't that great.
Yep ! share your script ! Not that I speak anything Perl...

Jean-Philippe
--
All Finagle Laws may be bypassed by learning the simple art of doing
without thinking.
Adriaan de Groot
2007-03-21 11:51:36 UTC
Permalink
Post by Joao-Philippe
Post by Boyan Tabakov
That great - someone noticed my signatures! :) Another thing you can do
is write a simple shell/other script that gives more control on the
output. In my case this is a perl script that prints some extra stuff
besides the fortune output (and furtune uses my custom made Nightwish
quotes).
On my Slack box, I got a "hitchhiker" fortune, but it isn't that great.
Yep ! share your script ! Not that I speak anything Perl...
Here's one I use, which you can easily adapt to read the strings from a file.
I've removed the taglines I use, just fill in @tags and perhaps print some
fixed strings at the end.

#! /usr/bin/env perl
use strict;
use Text::Wrap;

my @tags = (
# Put strings here
);

my $l = 0 + @tags;

$Text::Wrap::columns = 72;
print "-- \n"; # email signature delimiter
print wrap('','',$tags[int(rand($l))]) . "\n";
# Print other static content if you wish
--
KDE Quality Team http://www.englishbreakfastnetwork.org/
GPG: FEA2 A3FE http://people.fruitsalad.org/adridg/
"It is impossible to make an emphatic point with only two arms."
Jean-Philippe
2007-03-21 11:08:08 UTC
Permalink
Post by Adriaan de Groot
Here's one I use, which you can easily adapt to read the strings from a
some fixed strings at the end.
#! /usr/bin/env perl
use strict;
use Text::Wrap;
# Put strings here
);
$Text::Wrap::columns = 72;
print "-- \n"; # email signature delimiter
print wrap('','',$tags[int(rand($l))]) . "\n";
# Print other static content if you wish
Nice - would you mind re-post with the tags :) sorry I guess Tags are file
location or something like that but, hum, well, I plain don't know actually !

Are "fixed strings at the end" just plain
print "hello World"


??

Jean-Philippe
--
"Calling EMACS an editor is like calling the Earth a hunk of dirt."

-- Chris DiBona on Dirt (Open Sources, 1999 O'Reilly and Associates)
Jean-Philippe
2007-03-21 11:20:13 UTC
Permalink
Post by Joao-Philippe
Hi Community
I noticed Boyan to have ever-changing sigs based, I imagine, on the output
of something like "fortune".
How one does achieve this ?
Cheers - a link to some HowTo will do.
Jean-Philippe
Anyone caring to this futile conversation could find alot more fortune cookies
here:

http://freshmeat.net/browse/895/

Cheers community.
--
printk("%s: huh ? Who issued this format command ?\n")
linux-2.6.6/drivers/block/ps2esdi.c
Art Alexion
2007-03-27 00:44:32 UTC
Permalink
Post by Boyan Tabakov
Attached are the fortune file, along with the .dat string index file
(copy those to fortune folder, which on SuSE is /usr/share/fortune).
The file signature is my perl script that takes one argument - blade,
formal or cnsys - and prints the corresponding signature. It is nothing
special.
Boyan, thanks for sharing this, but the archive I got was corrupted. Ark
could open but not extract it. Care to send again off list, please. No
need to send the dat file I only want to look at the perl script
Here you go... only the perl script...
Thanks, Boyan. By the way, you apply to the KDE-ev? Are you planning to go
to Glasgow?
--
_____________________________________________________________
Art Alexion

PGP fingerprint: 52A4 B10C AA73 096F A661 92D2 3B65 8EAC ACC5 BA7A
Keyserver: hkp://subkeys.pgp.net
The attachment - signature.asc - is my electronic signature; no need for
alarm. Info @
http://mysite.verizon.net/art.alexion/encryption/signature.asc.what.html
_____________________________________________________________
Continue reading on narkive:
Loading...