Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - gregben

#1
Happy New Year!



I just downloaded and built version 9.0.0 on Solaris 8

and these are a few thoughts.



# Building under Linux, Solaris, and other Unix derivatives.



create make targets 'check' and 'test' which are synonyms

and run the qa-* scripts. The qa-* scripts along with any

related information should be relocated to a subdirectory

'test' in the source distribution.



The qa-* scripts should look for the newly built newLISP

executable in .. rather than /usr/bin/newlisp since newlisp

should not/may not have been installed yet, so:

#!../newlisp

rather than:

#!/usr/bin/newlisp



The default installation location for the newlisp executable

should be /usr/local/bin rather than /usr/bin. On the systems

I administer /usr/bin is used for rather static programs provided

as part of the core distribution and is not used for add-on

applications or utilities. In the specific case of Sun Solaris,

the programs in /usr/bin are checked using md5sums against Sun's

database to insure that the programs haven't been compromised

by a rootkit. By keeping /usr/bin free of add-on programs it is

easier to validate the programs.
#2
The following code:

(device (open "myfile" "a"))
(print "This goes in myfile")
(close (device))
(exit)

fails with: value expected : (open "myfile" "a")



when the file "myfile" doesn't exist.

If you use (on Unix):



#touch myfile



And rerun the code above, it works as expected.



I would expect that a file opened for appending with "a"

or "append" would not require preexistence of the

file to start writing to it. This is the common usage,

at least on Unix systems.
#3
The following example in the documentation is incorrect:



(device (open "myfile" "write"))  => 5

(print "This goes in myfile")     => "This goes in myfile.dat"

(close (device))                  => true



It should be:



(device (open "myfile" "write"))  => 5

(print "This goes in myfile")     => "This goes in myfile"

(close (device))                  => true



note .dat suffix removed from comment on line

starting with (print...
#4
Anything else we might add? /
April 02, 2005, 12:20:08 AM
Hilarious!



I especially liked the slider controls and the verbosity=10

comments.



Thank you for the link!
#5
newLISP newS / my 2 cents
March 31, 2005, 11:33:01 PM
A couple of comments on the new layout:



1) I prefer web pages that make full use of the available screen

width, generally by using three columns.

The laptop I use to read the forum

is 1280 x 800 pixels so it has a lot of width but not so much

height. This makes for a lot of vertical scrolling especially

when you consider the tab bar, tool bar, icon bar, address bar,

menu bar, and window title (using Firefox) that take up vertical

space.



2) The forum index page title should be something like "NewLISP Fan Club"

instead of ":: Index".



3) There should be a favicon.ico file so that you can have a little

icon on the tab bar (Firefox again). To see an example, go

to newlisp.org and look at the page source.
#6
I'm trying to write a program in Newlisp that

runs under Sun Solaris and:



1) Makes a list of md5 signatures of all files in /usr/bin.

2) Sends sections "chunks" of the signature list to a

    special web page operated by Sun Microsystems for

    checking against a database of known-good signatures.

3) Search the results returned by Sun for suspect file

    names, that is, those with signatures that weren't found

    in the database.



In the past I'd have written such a program in sh/bash or

perl. Here's what I've done so far using Newlisp. I'm looking

to clean the code up to improve efficiency and legibility.







#!/usr/bin/newlisp
#
# md5check
#
# Look for files in /usr/bin on the local machine that
# have md5 signatures that don't match those stored in
# the Sun Fingerprint database. This could indicate the
# file is a maliciously installed replacement for the
# genuine file supplied by Sun.

# The maximum number of md5 signatures passed to the
# Sun Fingerprint web page at one time. This is due to
# a restriction imposed by Sun on the number of lookups
# that can be done at once.

(constant 'md5s_at_once 100)

# The Sun fingerprint database URL.

(constant 'fingerprint_page "http://sunsolve.sun.com/pub-cgi/fileFingerprints.pl")

# Calculate the md5 signatures.

(set 'md5list (exec "cd /usr/bin ; md5sum *"))

# Prepare to loop through the signatures.

(set 'linecount 0)
(set 'md5_chunk "")

# Loop through md5 signatures, breaking into chunks.

(dolist (md5item md5list)
  (set 'md5_chunk (append md5_chunk md5item "n"))
  (inc 'linecount)
  (if (= (% linecount md5s_at_once) 0)
    (begin
      # Prepend POST form variable name to chunk.
      (set 'md5_chunk (append "md5list=" md5_chunk))
      # Send chunk of signatures to Sun for lookup.
      (set 'result (post-url fingerprint_page md5_chunk ))
      # Search returned web page for non-matching files.
      (set 'no_match_list (exec {grep "- 0 match"} result))
#      (println result)
      (println no_match_list)
#      (println (regex "- 0 match" result))
#      (set 'splitup (parse result "n"))
#      (println splitup)
#      (dolist (spl splitup)
#        (println spl)
#      )
      (set 'md5_chunk "")
    )
  )
)

(exit)


I'd like to come up with something better than using grep,

but it doesn't appear that there's an equivalent builtin.



Also, grep returns true in addition to the string results. The

manual shows an example of feeding data into and out of

an external command using exec, but not both at once as

I'm doing (sending a big string in and getting a big string out).
#7
Anything else we might add? /
March 08, 2005, 05:10:02 PM
you forgot Ruby.
#8
It ain't 'ewLISP' my friend, it's 'NewLISP'.



Seriously though, I just compiled NewLISP v 8.4.0 under

Sun Sparc Solaris 8 and noticed the inital 'N' was missing

from the output of 'newlisp -h'.

Rather than search through the source, I thought I'd

let you all take a look...



ca1$ ./newlisp -h

ewLISP v.8.4.0 Copyright (c) 2005 Lutz Mueller. All rights reserved.

usage: newlisp [file ...] [options ...] [file ...]

options:

 -h this help
 -s <stacksize>
 -m <max-mem-megabyte>
 -c suppress prompts
 -l log connections only
 -L log all
 -p <port-number>
 -d <port-number>
 -x <port-number>
 -e <quoted lisp expression>

for more information see http://newlisp.org
#9
newLISP in the real world /
November 02, 2004, 04:35:19 PM
Thanks, Lutz.



It would be nice to have "see also (exec)"

in the manual entries for (!) and (process).
#10
Is there an easy way to capture the stdout (and stderr) output

of an external command run using (!) without using files?



I'd like to be able to do something like:



(set 'file04 (! "ls -l | grep 2004"))



and have the result be the string spit out by

grep instead of the return code as (!) does now.



Perhaps the set of $ variables could be extended

to include a $stdout and $stderr such that after

running the above $stdout would contain the output

of grep and $stderr would be nil.



Another approach would be to redefine (!) to return

a list containing the result code, stdout, and stderr

as in:



(! "echo 'abc' ") --> ( 0 "abc" nil).
#11
newLISP in the real world /
November 02, 2004, 01:41:01 PM
Not that it helps, but I tried (process "newlisp") under Solaris 8 and got

three processes too.
#12
Anything else we might add? /
October 23, 2004, 08:42:51 PM
Thanks, Lutz for all your feedback. :-)



Here's a little function I wrote that  is sort of useful

without using regex or replace.



#!/usr/bin/newlisp



(define (initial-capital str)

  (nth-set 0 str (upper-case (nth 0 str)))

  str

)





(println (initial-capital "abc"))

(exit)
#13
Anything else we might add? /
October 23, 2004, 08:19:59 PM
Try this in perl:



#!/usr/bin/perl



$a = "aaa";

$a =~ s/^w/x/;

print "$a=$an";



You will get $a="xaa". This is correct in Perl,

and is what I want newLisp to do.



To anyone who's interested, the pattern

/^w/ means match any single "word" character

at the beginning of the string. This is the correct

function of the "^" character.
#14
I'm trying to replace the initial character of a string

(actually, I'm trying to do something more complex, but this is the gist of it).

I tried the following under newLisp 8.2.0 (Sparc Solaris 8) and got the following:



> (replace "a" "aaa" (upper-case $0) 0)

"AAA"

> (replace "^a" "aaa" (upper-case $0) 0)

"AAA"

> (replace "a$" "aaa" (upper-case $0) 0)

"aaA"

> (replace "^a" "aaa" (upper-case $0) 0)

"AAA"

> (replace "xa" "aaa" (upper-case $0) 0)

"aaa"



Note that I expected:

(replace "^a" "aaa" (upper-case $0) 0) to yield "Aaa".

See that "a$" works as expected.

I put in "^a" just for grins, but I expected "aaa" from it.



I suspect this is my fault, but perhaps it is a bug in pcre.c

or newLisp?
#15
newLISP in the real world / How about a test suite?
August 17, 2004, 11:09:59 PM
It would be nice to have a 'make test' or 'make check' option

after running 'make' when building Newlisp. It could help speed

debugging on "non-supported" platforms like Solaris.



I'm willing to be an "official" Solaris tester if this would help.



I'm thinking of something along the lines of the test suite

in php and a number of other projects.