🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #127339

Re: slrn - Will it show uptime like Mutt?

#127339
From: Matt H
Date: Sun, 29 Jun 2003 21:56
88 lines
3839 bytes
On Sun, 29 Jun 2003 00:33:05 GMT,
Crashdamage <tmeador@nospam.invalid> wrote:
> 
> On Sat, 28 Jun 2003 23:00:48 GMT, SINNER wrote:
>> While strolling through news.software.readers, Crashdamage was overheard
>> plotting:
>>> Thanks, from what I can tell it might, but I'm not sure.  I don't do French,
>>> so I'll have to wait 'til my daughter who does has a chance to do a little
>>> translation for me.
>> 
>> You dont need to understand french. Place that script in a file called
>> uptime.sl and interpret it in your slrnrc.
> 
> OK, I'd already done that and yeah it works, but it trashes my 
> 
> "X-Newsreader SLRN 0.9.7.4 (Linux)"

This because it completely overwrites 'custom_headers', at the end of this post
I have included a fixed version of hooks.sl that will keep any previous value
of custom_headers and only add the uptime to it.

> header line when I use it.  Also, I can't figure how to add my entire
> uptime command including the sed command to strip out extra info (this
> actually is a line I ripped off Sven Guckes' muttrc):
> 
> "`uptime | sed -e 's/.*up \([^,]*\),.*/\1/'`"
> 
> I added it to the command line like this:
> 
> uptime="";
>   cmd = sprintf("uptime | sed -e 's/.*up \([^,]*\),.*/\1/'" );
> 
> and I thought that would do it, but it gets ignored and still puts the
> whole verbose "uptime" command in the header.  

Can you try putting the `uptime | sed -e 's/.*up \([^,]*\),.*/\1/'` into a shell
script and then executing the script instead of the uptime command? I think that
would proabably work.

Here is the fixed version of hooks.sl that will not destroy 'custom_header'.

% hooks.sl

define get_uptime () {
	variable uptime;
	variable buf;
	variable fp;
	variable cmd;

	uptime = "";
	cmd = sprintf("uptime");
	fp = popen(cmd,"r");
	if (fp == NULL) {
		message("Can not include uptime...");
	}
	else {
		buf = "";
		while (-1 != fgets(&buf, fp)) {
			uptime = sprintf("%s%s", uptime, buf);
		} () = pclose(fp);
	} return uptime;
}

define post_hook_uptime () {
	variable uptime;
	variable old_custom_header;

	old_custom_header = get_variable_value ("custom_headers");
	uptime = get_uptime();
	uptime = sprintf("X-Uptime: %s", uptime);
	set_string_variable("custom_headers", sprintf("%s%s%s", old_custom_header, "\n", uptime));
}

define followup_hook_uptime () {
	variable uptime;
	uptime = get_uptime();
	uptime = sprintf("X-Uptime: %s", uptime);
	set_string_variable("followup_custom_headers", uptime);
}

define post_hook () {
	post_hook_uptime();
}

define followup_hook () {
	followup_hook_uptime();
}
Technical Details
Message-ID: <slrnbfuo41.ci4.nntp@distraction.ath.cx>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!cox.net!news-xfer.cox.net!p01!fed1read07.POSTED!not-for-mail
References: <5b5d4e99f7010bc79d6f175b05231f5a@free.teranews.com> <slrnbfrlo2.aia.mark_usenet@bubble.markhill.me.uk> <2c8b5b5781cd49e472818395d8a46aa5@free.teranews.com> <k0j1t-m62.ln1@news.gates_of_hell.INVALID> <0f3aae932af5b69aaae9ca9cab521c94@free.teranews.com>

Show Full Headers
Complete Article Headers
Message-ID: <slrnbfuo41.ci4.nntp@distraction.ath.cx>
Subject: Re: slrn - Will it show uptime like Mutt?
Date: Sun, 29 Jun 2003 21:56:18 GMT
From: Matt H <nntp@cox.net>
References: <5b5d4e99f7010bc79d6f175b05231f5a@free.teranews.com> <slrnbfrlo2.aia.mark_usenet@bubble.markhill.me.uk> <2c8b5b5781cd49e472818395d8a46aa5@free.teranews.com> <k0j1t-m62.ln1@news.gates_of_hell.INVALID> <0f3aae932af5b69aaae9ca9cab521c94@free.teranews.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!cox.net!news-xfer.cox.net!p01!fed1read07.POSTED!not-for-mail
Newsgroups: news.software.readers
X-Uptime: 14:46:50 up 10:17, 4 users, load average: 0.13, 0.08, 0.09
User-Agent: slrn/0.9.7.4 (Linux)
Lines: 87
NNTP-Posting-Host: 68.3.8.202
X-Complaints-To: abuse@cox.net
X-Trace: fed1read07 1056923778 68.3.8.202 (Sun, 29 Jun 2003 17:56:18 EDT)
NNTP-Posting-Date: Sun, 29 Jun 2003 17:56:18 EDT
Organization: Cox Communications