Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Core and stdin

 [1/10] from: marek:babik:dwory:pl at: 10-Apr-2001 13:17


Hi! Is there any posibility to catch data from stdin with REBOL/Core? I mean: cat file.txt |rebol -w script.r Does it require shell extension (Command, View/Pro)? Regards. -- [marek--babik--dwory--pl]

 [2/10] from: biker::timsi::com::pl at: 10-Apr-2001 20:21


Hi! Is this possible to catch data from stdin with REBOL/Core? (something like: cat file.txt |rebol -w script.r ) Does it require /Command or /View/Pro (shell extension)? Regards. -- 2ker uin: 5901548

 [3/10] from: brian:hawley at: 12-Apr-2001 15:15


2ker wrote:
>Is this possible to catch data from stdin with REBOL/Core? >(something like: cat file.txt |rebol -w script.r ) >Does it require /Command or /View/Pro (shell extension)?
It depends on whether you're running Windows or something more Unix-like. On Unix-like systems, I/O redirection is done without difficulties. On Windows the | operator does not work with REBOL, just > and <. You can do full I/O redirection from within REBOL with the shell functions of /Command and /Pro, but in REBOL syntax. See the docs on the shell functions on the REBOL site, but before you ask: No, you can't use the | operator with /Pro or /Command on Windows either. My advise: Get /Pro and use REBOL scripts as the main glue to call all of the external programs, instead of DOS batch language (useless) or Perl (ugly) :) Brian Hawley

 [4/10] from: kracik:mbox:dkm:cz at: 13-Apr-2001 20:17


Brian Hawley wrote:
> >actually, pipe can be used for redirecting REBOL input and output in > >Windows. The problem is that Windows does not have the cat command, > > If you don't have Cygwin, try the type command. > Better yet, why cat into a pipe at all? Use the < operator instead. >
Cat is needed for printing REBOL output to the console, not for piping input into REBOL. Unfortunately, type command does not accept input from stdin, more freezes after one page and waits for user input, and findstr is missing in Windows 9x. If you find some other Windows command that works like cat, let me know. I use cygwin tools, but I needed a solution that works on all Windows installations. Actually, I needed that for printing msdev output to the console, but then I discovered that it works with REBOL as well.
> ... > >What surprised me, piping input into REBOL works as well, if output
<<quoted lines omitted: 5>>
> That never occurred to me! I just tried it and it works. Cool! > Now I can rewrite the workarounds I've made over the years :)
Until I tried it this morning, I also thought it was impossible :-) Now that we know it, it's clear - after all, REBOL works in CGI mode in Windows, and that requires stdin and stdout connected with pipes to the web server. -- Michal Kracik

 [5/10] from: kracik:mbox:dkm:cz at: 13-Apr-2001 9:05


Hi, actually, pipe can be used for redirecting REBOL input and output in Windows. The problem is that Windows does not have the cat command, and few other commands support input from stdin. You can try this in Windows command prompt in all Windows versions: C:\REBOL\test>rebol -wq --do "print {Hello World} quit" | more Hello World or this in Windows NT and 2000: C:\REBOL\test>rebol -wq --do "print {Hello World} quit" | findstr . Hello World What surprised me, piping input into REBOL works as well, if output is also redirected: C:\REBOL\test>echo "Hello REBOL" | rebol -wq --do "print [ {from stdin:} input ] quit" | more from stdin: "Hello REBOL" Regards, Michal Kracik Brian Hawley wrote:

 [6/10] from: biker:timsi:pl at: 13-Apr-2001 10:06


At 15:15 2001-4-12 -0500, you wrote:
>more Unix-like. On Unix-like systems, I/O redirection is >done without difficulties. On Windows the | operator does >not work with REBOL, just > and <.
It's linux, so pipe should do the job. (but doesn't :( I'm working on some kind of "webgate" for majordomo-driven mailing list. All incoming messages are prefiltered by procmail, and some of them should be piped to rebol script. After bit of cleanup, messages should be inserted into MySQL database. Everything runs fine. Everything but piping msgs to script :(
>You can do full I/O redirection from within REBOL with the >shell functions of /Command and /Pro, but in REBOL syntax. ><...>
/Command and /Pro shell functions... so it won't work with /Core :( Thanks for advice. I was worried that my question was too "lame" ;) ........ ::2ker:: uin: 5901548

 [7/10] from: biker:timsi:pl at: 13-Apr-2001 10:24


At 09:05 2001-4-13 +0000, you wrote:
>Hi, > >actually, pipe can be used for redirecting REBOL input and output in >Windows. The problem is that Windows does not have the cat command, >and few other commands support input from stdin. You can try this in
I'm using "cat" from cygwin32 tools.
><...> >What surprised me, piping input into REBOL works as well, if output >is also redirected: > >C:\REBOL\test>echo "Hello REBOL" | rebol -wq --do "print [ {from stdin:} >input ] quit" | more >from stdin: "Hello REBOL"
The problem was that I made some "typo" in my script on linux, and then tried to figure what is going on on Windows :) Big thanks!!! ........ ::2ker:: uin: 5901548

 [8/10] from: alan_otterstad:mikronvinyl at: 13-Apr-2001 9:29


Can't you download the GNU utilities for windows and use them instead??? I haven't tried it myself but I do know that there are unix commands available thru GNU utilities. I have them on my pc and they work very similarly to the unix commands as far as I know. So you might try downloading them and see if they work the way you want to. alan Hi, actually, pipe can be used for redirecting REBOL input and output in Windows. The problem is that Windows does not have the cat command, and few other commands support input from stdin. You can try this in Windows command prompt in all Windows versions: C:\REBOL\test>rebol -wq --do "print {Hello World} quit" | more Hello World or this in Windows NT and 2000: C:\REBOL\test>rebol -wq --do "print {Hello World} quit" | findstr . Hello World What surprised me, piping input into REBOL works as well, if output is also redirected: C:\REBOL\test>echo "Hello REBOL" | rebol -wq --do "print [ {from stdin:} input ] quit" | more from stdin: "Hello REBOL" Regards, Michal Kracik Brian Hawley wrote:

 [9/10] from: brian:hawley at: 13-Apr-2001 12:24


Michal Kracik wrote:
>actually, pipe can be used for redirecting REBOL input and output in >Windows. The problem is that Windows does not have the cat command,
If you don't have Cygwin, try the type command. Better yet, why cat into a pipe at all? Use the < operator instead. ...
>What surprised me, piping input into REBOL works as well, if output >is also redirected: > >C:\REBOL\test>echo "Hello REBOL" | rebol -wq --do "print [ {from stdin:} >input ] quit" | more >from stdin: "Hello REBOL"
That never occurred to me! I just tried it and it works. Cool! Now I can rewrite the workarounds I've made over the years :) Thanks! Brian Hawley

 [10/10] from: kracik:mbox:dkm:cz at: 13-Apr-2001 19:51


Yes, I have them, but they need the cygwin dll, and maybe some installation. What's strange is that Windows does not contain cat or something similar in it's installation, when it already contains everything but the kitchen sink :-) -- Michal Kracik [Alan_Otterstad--mikronvinyl--com] wrote:

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted