From: gavino
Subject: why does this clisp uptime script not work?
Date: 
Message-ID: <e2a6a35a-c1a2-4f24-afe4-72eceee44f7a@s8g2000prg.googlegroups.com>
http://clisp.wiki.sourceforge.net/shell+scripting

I ran this a few times, my clisp is in /usr/bin/clisp ..... comes back
with nothing...

anyone know why?

linux

From: ···············@gmail.com
Subject: Re: why does this clisp uptime script not work?
Date: 
Message-ID: <88d7ccb0-ae34-4646-9e56-491e879ded47@s13g2000prd.googlegroups.com>
On Mar 25, 8:29 pm, gavino <·········@gmail.com> wrote:
> http://clisp.wiki.sourceforge.net/shell+scripting
>
> I ran this a few times, my clisp is in /usr/bin/clisp ..... comes back
> with nothing...
>
> anyone know why?
>
> linux

It works OK for me. I'm sure you've tried all of these but off the top
of my head:

- What system are you running?
- Does /proc/uptime exist on your system?
- Does your account have rights to read it (what does cat /proc/uptime
give you)?
- Have you marked the script as executable? (chmod +x)

--
Phil
http://phil.nullable.eu/
From: gavino
Subject: Re: why does this clisp uptime script not work?
Date: 
Message-ID: <e6bc10bd-d020-4b98-958d-3f34ee35b885@e10g2000prf.googlegroups.com>
On Mar 25, 2:39 pm, ···············@gmail.com wrote:
> On Mar 25, 8:29 pm, gavino <·········@gmail.com> wrote:
>
> >http://clisp.wiki.sourceforge.net/shell+scripting
>
> > I ran this a few times, my clisp is in /usr/bin/clisp ..... comes back
> > with nothing...
>
> > anyone know why?
>
> > linux
>
> It works OK for me. I'm sure you've tried all of these but off the top
> of my head:
>
> - What system are you running?
> - Does /proc/uptime exist on your system?
> - Does your account have rights to read it (what does cat /proc/uptime
> give you)?
> - Have you marked the script as executable? (chmod +x)
>
> --
> Philhttp://phil.nullable.eu/

archlinux
/proc/uptime returns some interesting numbers
yep chmod 777
 so it works for you when invoked how? ./clisp-uptime.sh ???
From: Brian
Subject: Re: why does this clisp uptime script not work?
Date: 
Message-ID: <3b2e5649-8408-4963-a56f-a82d58668a96@8g2000hse.googlegroups.com>
Works for me under Kubuntu.  Just pasted it into Emacs, saved it, did
chmod +x, and ./clisp-uptime.sh worked.

I use clisp for another shell script and that has always worked also.
From: Kaz Kylheku
Subject: Re: why does this clisp uptime script not work?
Date: 
Message-ID: <d6f24079-e3a2-4f0c-9156-6b068a9312fb@s50g2000hsb.googlegroups.com>
On Mar 25, 1:29 pm, gavino <·········@gmail.com> wrote:
> http://clisp.wiki.sourceforge.net/shell+scripting
>
> I ran this a few times, my clisp is in /usr/bin/clisp ..... comes back
> with nothing...
>
> anyone know why?

Welcome to debugging.

You have to isolate the problem.

What if you put this into a text file, mark it executable and run it?

  #!/usr/bin/clisp
  (write-string "Hello, world!)
  (terpri)

If this doesn't work for whatever reason, then the more complicated
uptime script doesn't have a chance.
From: gavino
Subject: Re: why does this clisp uptime script not work?
Date: 
Message-ID: <d86e4f2d-42f3-428c-a08f-263fb7d69bbc@e6g2000prf.googlegroups.com>
On Mar 25, 4:20 pm, Kaz Kylheku <········@gmail.com> wrote:
> On Mar 25, 1:29 pm, gavino <·········@gmail.com> wrote:
>
> >http://clisp.wiki.sourceforge.net/shell+scripting
>
> > I ran this a few times, my clisp is in /usr/bin/clisp ..... comes back
> > with nothing...
>
> > anyone know why?
>
> Welcome to debugging.
>
> You have to isolate the problem.
>
> What if you put this into a text file, mark it executable and run it?
>
>   #!/usr/bin/clisp
>   (write-string "Hello, world!)
>   (terpri)
>
> If this doesn't work for whatever reason, then the more complicated
> uptime script doesn't have a chance.

   #!/usr/bin/clisp
   (write-string "Hello, world!")
   (terpri)
works (with my added right ")
hmmmm..
From: Kaz Kylheku
Subject: Re: why does this clisp uptime script not work?
Date: 
Message-ID: <f5724894-1a32-4b91-a12d-ac3fac350000@d62g2000hsf.googlegroups.com>
On Mar 25, 1:29 pm, gavino <·········@gmail.com> wrote:
> http://clisp.wiki.sourceforge.net/shell+scripting

The script has a bug; it doesn't terminate the line of output that it
produces:

(defun show-hms-time(seconds)
    (multiple-value-bind (h m s) (generate-hms seconds)
        (format t "Uptime: ~a hours, ~a minutes, ~a seconds" h m s)))

This should be:

        (format t "Uptime: ~a hours, ~a minutes, ~a seconds~%" h m s)

Now I tried it on a CLISP 2.38 installation that I have handy over
here, and the newline is produced anyway. There must be special logic
in CLISP's text streams to not only flush any unbuffered output, but
also to properly terminate with a newline if the program closes a
stream abruptly in the middle of a line.

Suppose that the CLISP installation you have handles abrupt stream
closure differently. Maybe it has a bug whereby it doesn't flush the
last buffered output? Such an issue would be masked in a program that
triggers flushing by issuing a newline.

Suppose that the CLISP version you have /does/ flush the output
properly when a stream is closed (on normal program termination or
otherwise), but suppose that it does not automatically add the missing
newline. Furthermore, suppose that you have a fancy shell prompt which
performs cursor positioning within the line. In that case, the
improperly terminated output of the program could be overwritten by
the prompt, and this could happen so quickly that you never see it.

What version of CLISP is that? What do you see when you run clisp --
version?

> I ran this a few times, my clisp is in /usr/bin/clisp ..... comes back
> with nothing...

What if you redirect the output to a file? Is the file empty?

What if you change to a plain prompt? E.g   PS1='\h:\w\$ '  under GNU
bash?

What do you see if you run ``strace'' on the program, particularly
near the end of the trace?
From: gavino
Subject: Re: why does this clisp uptime script not work?
Date: 
Message-ID: <97d46443-f784-4bdd-a1ce-7af4c15115c5@s19g2000prg.googlegroups.com>
On Mar 25, 4:42 pm, Kaz Kylheku <········@gmail.com> wrote:
> On Mar 25, 1:29 pm, gavino <·········@gmail.com> wrote:
>
> >http://clisp.wiki.sourceforge.net/shell+scripting
>
> The script has a bug; it doesn't terminate the line of output that it
> produces:
>
> (defun show-hms-time(seconds)
>     (multiple-value-bind (h m s) (generate-hms seconds)
>         (format t "Uptime: ~a hours, ~a minutes, ~a seconds" h m s)))
>
> This should be:
>
>         (format t "Uptime: ~a hours, ~a minutes, ~a seconds~%" h m s)
>
> Now I tried it on a CLISP 2.38 installation that I have handy over
> here, and the newline is produced anyway. There must be special logic
> in CLISP's text streams to not only flush any unbuffered output, but
> also to properly terminate with a newline if the program closes a
> stream abruptly in the middle of a line.
>
> Suppose that the CLISP installation you have handles abrupt stream
> closure differently. Maybe it has a bug whereby it doesn't flush the
> last buffered output? Such an issue would be masked in a program that
> triggers flushing by issuing a newline.
>
> Suppose that the CLISP version you have /does/ flush the output
> properly when a stream is closed (on normal program termination or
> otherwise), but suppose that it does not automatically add the missing
> newline. Furthermore, suppose that you have a fancy shell prompt which
> performs cursor positioning within the line. In that case, the
> improperly terminated output of the program could be overwritten by
> the prompt, and this could happen so quickly that you never see it.
>
> What version of CLISP is that? What do you see when you run clisp --
> version?
>
> > I ran this a few times, my clisp is in /usr/bin/clisp ..... comes back
> > with nothing...
>
> What if you redirect the output to a file? Is the file empty?
>
> What if you change to a plain prompt? E.g   PS1='\h:\w\$ '  under GNU
> bash?
>
> What do you see if you run ``strace'' on the program, particularly
> near the end of the trace?

It works now.  I must have miscopied the text while using putty on
windows.  On my archlinux box it is fine.  Wow now i know why FUDD is
so deadly.

[····@myhost lisp]# ./clisp-uptime.sh
Uptime: 29 hours, 15 minutes, 59 seconds

NICE

PS it also worked without your ~% correction:
[····@myhost lisp]# ./clisp-uptime.sh
Uptime: 29 hours, 18 minutes, 26 seconds

bravo CLISP!! Thank you gents!