Hello, As you can see from my signature in this message, I use the R fortune function to generate a fortune, which is then fed to the signature program, which constructs a named pipe containing the fortune-bearing sig, which is then included in mail messages. The problem is that it's got extraneous junk in it and I can't figure out how to get rid of it. This is the command that generates the fortune: /usr/bin/R --no-save --no-restore -q < /home/sl70/print-fortune.R (where print-fortune.R is just library(fortunes) fortune() ) This produces this:> library(fortunes) > fortune()Michael Watson: Hopefully this one isn't in the manual or I am about to get shot :-S Peter Dalgaard: *Kapow*... -- Michael Watson and Peter Dalgaard (question on axis()) R-help (February 2006)>I would like to remove the first two lines and the last line, so I changed the command to this: /usr/bin/R --no-save --no-restore < /home/sl70/print-fortune.R |tail \ -n +23 | head -n -2 2> /dev/null That give the desired result when I run it at the command line, but when I feed it to the signature program, I get this message: Program /usr/local/bin/r-fortune doesn't seem to exist This is the signature program code that produces this error: /* check for existence of program by forking and then trying to exec() it in the child */ pid = fork(); switch (pid) { case -1: /* oh well */ perror("Couldn't fork() a child process"); exit(EXIT_FAILURE); case 0: /* in child */ /* close stdout */ close(1); execlp(producer, producer, (char *) 0); exit(EXIT_FAILURE); default: waitpid(pid, &exit_status, 0); if (exit_status != EXIT_SUCCESS) { fprintf(stderr, "Program %s doesn't seem to exist \n", producer); exit(EXIT_FAILURE); } Unfortunately, I don't understand this at all. Can anyone give me a clue as to what's happening? Thanks. -- Stuart Luppescu -=- slu .at. ccsr.uchicago.edu University of Chicago -=- CCSR ???????? -=- Kernel 2.6.33-gentoo-r2> library(fortunes) > fortune() Overall, SAS isabout 11 years behind R and S-Plus in statistical capabilities (last year it was about 10 years behind) in my estimation. -- Frank Harrell (SAS User, 1969-1991) R-help (September 2003) >
On Sep 1, 2010, at 4:49 PM, Stuart Luppescu wrote:> Hello, As you can see from my signature in this message, I use the R > fortune function to generate a fortune, which is then fed to the > signature program, which constructs a named pipe containing the > fortune-bearing sig, which is then included in mail messages. The > problem is that it's got extraneous junk in it and I can't figure out > how to get rid of it. This is the command that generates the fortune: > > /usr/bin/R --no-save --no-restore -q < /home/sl70/print-fortune.R > (where print-fortune.R is just > library(fortunes) > fortune() > ) > > This produces this: >> library(fortunes) >> fortune() > > Michael Watson: Hopefully this one isn't in the manual or I am about > to get shot :-S > Peter Dalgaard: *Kapow*... > -- Michael Watson and Peter Dalgaard (question on axis()) > R-help (February 2006) > >> > > I would like to remove the first two lines and the last line, so I > changed the command to this: > /usr/bin/R --no-save --no-restore < /home/sl70/print-fortune.R | > tail \ > -n +23 | head -n -2 2> /dev/null > > That give the desired result when I run it at the command line, but > when > I feed it to the signature program, I get this message: > > Program /usr/local/bin/r-fortune doesn't seem to exist > > This is the signature program code that produces this error: > > /* check for existence of program by forking and then trying > to > exec() it in the child */ > pid = fork(); > switch (pid) { > case -1: /* oh well */ > perror("Couldn't fork() a child process"); > exit(EXIT_FAILURE); > case 0: /* in child */ > /* close stdout */ > close(1); > execlp(producer, producer, (char *) 0); > exit(EXIT_FAILURE); > default: > waitpid(pid, &exit_status, 0); > if (exit_status != EXIT_SUCCESS) { > fprintf(stderr, "Program %s doesn't seem to exist > \n", > producer); > exit(EXIT_FAILURE); > } > > Unfortunately, I don't understand this at all. Can anyone give me a > clue > as to what's happening? > > Thanks. > -- > Stuart Luppescu -=- slu .at. ccsr.uchicago.edu > University of Chicago -=- CCSR > ???????? -=- Kernel 2.6.33-gentoo-r2 >> library(fortunes) > fortune() Overall, SAS is > about 11 years behind R and S-Plus in statistical > capabilities (last year it was about 10 years > behind) in my estimation. -- Frank Harrell (SAS > User, 1969-1991) R-help (September 2003) > > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD West Hartford, CT
Dirk Eddelbuettel
2010-Sep-01 21:18 UTC
[R] [semi-OT] Using fortune() in an email signature
On 1 September 2010 at 15:49, Stuart Luppescu wrote:
| Hello, As you can see from my signature in this message, I use the R
| fortune function to generate a fortune, which is then fed to the
| signature program, which constructs a named pipe containing the
| fortune-bearing sig, which is then included in mail messages. The
| problem is that it's got extraneous junk in it and I can't figure out
| how to get rid of it. This is the command that generates the fortune:
|
| /usr/bin/R --no-save --no-restore -q < /home/sl70/print-fortune.R
| (where print-fortune.R is just
| library(fortunes)
| fortune()
| )
|
| This produces this:
| > library(fortunes)
| > fortune()
|
| Michael Watson: Hopefully this one isn't in the manual or I am about to
get shot :-S
| Peter Dalgaard: *Kapow*...
| -- Michael Watson and Peter Dalgaard (question on axis())
| R-help (February 2006)
|
| >
|
| I would like to remove the first two lines and the last line, so I
| changed the command to this:
| /usr/bin/R --no-save --no-restore < /home/sl70/print-fortune.R |tail \
| -n +23 | head -n -2 2> /dev/null
|
| That give the desired result when I run it at the command line, but when
| I feed it to the signature program, I get this message:
There are scripting front-ends to R for these tasks. A few years ago Jeff and
I released 'r' (aka littler), R Core followed up with Rscript a few
months
later. I still use r more.
In r / littler, all calls to library() are wrapped in suppressMessages()
because I too hate that echo from library loads. So here is what you could do:
edd at max:~$ r --package=fortunes --eval="print(fortune())"
Ah, so that's why my report of a bug in the RCheapViagra package didn't
get through....
-- Barry Rowlingson (after Peter Dalgaard announced a new spam filter for
R-bugs)
R-devel (January 2004)
edd at max:~$ r --package=fortunes --eval="print(fortune())"
I use R. My company benefits from it. My clients benefit from it.
...and I sleep just fine (when I do sleep)... :-)
-- Marc Schwartz, Medanalytics (about the 'costs' of free software)
R-help (June 2004)
edd at max:~$ r -lfortunes -e"print(fortune())" # shorter form
Soon, they'll be speaking R on the subway.
-- Michael Rennie (giving 'Kudos to the R support team')
R-help (July 2004)
edd at max:~$
Doing the same with Rscript is left as an exercise....
Cheers, Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Christian Raschke
2010-Sep-01 21:32 UTC
[R] [semi-OT] Using fortune() in an email signature
Simply using option --slave instead seems to do the trick.
$ /usr/bin/R --slave < test-fortune.R
Similarly to Brian, I'm much more reluctant to help people who don't
exist --
who knows, maybe you're a computer program who has just passed the
Turing test
:-)
-- Martin Maechler (about postings with anonymous e-mail addresses and
without real names)
R-help (March 2006)
CR
On 09/01/2010 03:49 PM, Stuart Luppescu wrote:> Hello, As you can see from my signature in this message, I use the R
> fortune function to generate a fortune, which is then fed to the
> signature program, which constructs a named pipe containing the
> fortune-bearing sig, which is then included in mail messages. The
> problem is that it's got extraneous junk in it and I can't figure
out
> how to get rid of it. This is the command that generates the fortune:
>
> /usr/bin/R --no-save --no-restore -q< /home/sl70/print-fortune.R
> (where print-fortune.R is just
> library(fortunes)
> fortune()
> )
>
> This produces this:
>
>> library(fortunes)
>> fortune()
>>
> Michael Watson: Hopefully this one isn't in the manual or I am about to
get shot :-S
> Peter Dalgaard: *Kapow*...
> -- Michael Watson and Peter Dalgaard (question on axis())
> R-help (February 2006)
>
>
>>
> I would like to remove the first two lines and the last line, so I
> changed the command to this:
> /usr/bin/R --no-save --no-restore< /home/sl70/print-fortune.R |tail \
> -n +23 | head -n -2 2> /dev/null
>
> That give the desired result when I run it at the command line, but when
> I feed it to the signature program, I get this message:
>
> Program /usr/local/bin/r-fortune doesn't seem to exist
>
> This is the signature program code that produces this error:
>
> /* check for existence of program by forking and then trying to
> exec() it in the child */
> pid = fork();
> switch (pid) {
> case -1: /* oh well */
> perror("Couldn't fork() a child process");
> exit(EXIT_FAILURE);
> case 0: /* in child */
> /* close stdout */
> close(1);
> execlp(producer, producer, (char *) 0);
> exit(EXIT_FAILURE);
> default:
> waitpid(pid,&exit_status, 0);
> if (exit_status != EXIT_SUCCESS) {
> fprintf(stderr, "Program %s doesn't seem to
exist
> \n",
> producer);
> exit(EXIT_FAILURE);
> }
>
> Unfortunately, I don't understand this at all. Can anyone give me a
clue
> as to what's happening?
>
> Thanks.
>
--
Christian Raschke
Department of Economics
and
ISDS Research Lab (HSRG)
Louisiana State University
Patrick Taylor Hall, Rm 2128
Baton Rouge, LA 70803
crasch2 at lsu.edu
Or using R & GNU tools:
matt at max:~$ R -e "fortunes::fortune()" | gawk '/^[^>]/
{print}'
It's not a question of trying variations, rather of following
instructions.
-- Brian D. Ripley (about using 'Writing R Extensions')
R-help (January 2006)
-Matt
On Wed, 2010-09-01 at 16:49 -0400, Stuart Luppescu
wrote:> Hello, As you can see from my signature in this message, I use the R
> fortune function to generate a fortune, which is then fed to the
> signature program, which constructs a named pipe containing the
> fortune-bearing sig, which is then included in mail messages. The
> problem is that it's got extraneous junk in it and I can't figure
out
> how to get rid of it. This is the command that generates the fortune:
>
> /usr/bin/R --no-save --no-restore -q < /home/sl70/print-fortune.R
> (where print-fortune.R is just
> library(fortunes)
> fortune()
> )
>
> This produces this:
> > library(fortunes)
> > fortune()
>
> Michael Watson: Hopefully this one isn't in the manual or I am about to
get shot :-S
> Peter Dalgaard: *Kapow*...
> -- Michael Watson and Peter Dalgaard (question on axis())
> R-help (February 2006)
>
> >
>
> I would like to remove the first two lines and the last line, so I
> changed the command to this:
> /usr/bin/R --no-save --no-restore < /home/sl70/print-fortune.R |tail \
> -n +23 | head -n -2 2> /dev/null
>
> That give the desired result when I run it at the command line, but when
> I feed it to the signature program, I get this message:
>
> Program /usr/local/bin/r-fortune doesn't seem to exist
>
> This is the signature program code that produces this error:
>
> /* check for existence of program by forking and then trying to
> exec() it in the child */
> pid = fork();
> switch (pid) {
> case -1: /* oh well */
> perror("Couldn't fork() a child process");
> exit(EXIT_FAILURE);
> case 0: /* in child */
> /* close stdout */
> close(1);
> execlp(producer, producer, (char *) 0);
> exit(EXIT_FAILURE);
> default:
> waitpid(pid, &exit_status, 0);
> if (exit_status != EXIT_SUCCESS) {
> fprintf(stderr, "Program %s doesn't seem to
exist
> \n",
> producer);
> exit(EXIT_FAILURE);
> }
>
> Unfortunately, I don't understand this at all. Can anyone give me a
clue
> as to what's happening?
>
> Thanks.
--
Matthew S. Shotwell
Graduate Student
Division of Biostatistics and Epidemiology
Medical University of South Carolina