Hi,
Pending the issue of the previous post (//http), I tried to solve it in a different way.
Similar to other core Unix programs, I tried to use a pipe to the STDIN of newLisp, but it fails. Below taken from the command prompt:
Quote
peter[~]$ echo "help" | awk '{print}'
help
peter[~]$ echo "help" | sed {}
help
peter[~]$ echo "help" | cut -f1
help
peter[~]$ echo "help" | newlisp -e "(println)"
nil
So how can I accept stdin to the newLisp binary and perform a task with it?
If newLisp wants to integrate in a Unix environment then it would be great if this works!
Thanks
not necessary, see my answer to your previous post, we posted at the same time.
and here is the solution to your pipe problem:
~> echo "help" | newlisp -e "(read-line)"
"help"
~>
Hi Lutz,
Indeed, the solution works fine!
However, just for arguments sake, how would you think about implementing a STDIN for newLisp? It would help a lot in different (Unix) situations if this is possible.
Just curious on your ideas about this.
Thanks
Peter
You're fast! It always worked, thanks a lot!
Complete list now:
Quote
peter[~]$ echo "help" | awk '{print}'
help
peter[~]$ echo "help" | sed {}
help
peter[~]$ echo "help" | cut -f1
help
peter[~]$ echo "help" | newlisp -e "(read-line)"
"help"
Peter
In this chapter: http://www.newlisp.org/CodePatterns.html#scripts you find the basic pattern of a UNIX filter written in newLISP:
~> echo "hello world" | ./filter
HELLO WORLD
~> cat filter
#!/usr/bin/newlisp
(while (read-line) (println (upper-case (current-line))))
(exit)
~>
'current-line' always contains the last result from 'read-line'. This pattern has been well tested in a UNIX environment. It also works with inetd for setting up servers.
ps: I am on your timezone ;-)
Aha! I was already wondering why you were responding so fast ;-)
Maybe time for another European Newlisp Conference? ;-)
Quote
Maybe time for another European Newlisp Conference? ;-)
Sure!