[REBOL] Re: More REBOL IOS questions.
From: gerardcote:sympatico:ca at: 13-May-2002 22:29
Hello Ed,
fortunately enough I just found some article of interest for one of your
question, at least I think it could be useful in regard with what I
understand of the many points you expressed below :
1 - > In what little testing I've done, it looks like, if I have to publish
> multiple scripts, I have to do it once for each one. Our development
> scripts are structured in a psuedo-object-oriented fashion. It would be
> convenient then to take a directory, or a group of files and publish
> them to IOS all at once.
>
2 - Case in point: can it call SQL*Plus, pass the
> > User and Password and script to be run? >>
> >
> >
3 - > I know IOS can detect file changes. Can it intercept those changes
programmatically? Can we use it to create a log of files that have been
changed?
> >
> I mean, within Link, using REBOL, can I intercept a change in a file and
> us it to fire of an action. It is functionality that we could use to
> help us manage our scripting process.
>
Here is the extract taken from the http://www.rebol.com/docs/rebolintro.html
page Carl Sassenrath wrote in july of 2001.
I just began to read it this afternoon. I really think it adresses the 3
points above in some way.
Hope this helps you as much as it is helping me in my new learning quest of
REBOL,
Gerard
8<---------------
To write a line that reads an image file and uploads it to an Internet
server, you can write:
write/binary ftp://user:[pass--example--com]/pub/link.jpg
read/binary %link.jpg
Notice that you must provide the username and password as part of the URL.
Do you want to upload an entire directory of files? This script does the
job:
site: ftp://user:[pass--example--com]/pub/
foreach file read %thefiles/ [
write/binary site/:file read/binary file
]
Notice there is another refinement being used on the site word. When a
refinement is used on a URL, it combines the URL with the file name that is
provided. The colon in front of file says "get the filename". Add a print to
the loop to see the result:
print site/:file
Perhaps you want to upload only the JPEG files from that directory. Check
the file names using find as was shown in the previous section:
foreach file read %thefiles/ [
if find file ".jpg" [
write/binary site/:file read/binary file
]
]
To upload all the GIF and JPEG files you can write:
foreach file read %thefiles/ [
if any [
find file ".jpg"
find file ".gif"
] [
write/binary site/:file read/binary file
]
]
Now, let's say you want to upload only the files that have changed in the
last two days:
date: now - 2
foreach file read %thefiles/ [
if (modified? file) > date [
write/binary site/:file read/binary file
]
]
The date variable is set by getting the current date and time, then
subtracting two days from it. This is compared to the date on the file,
which is obtained with the modified? function.
You could just as easily have written the loop to transfer files that were
smaller than a certain size replacing the comparison line with:
if (size? file) < 100000 [
Or, you could avoid subdirectories with:
if not dir? file [
These functions also work with URLs. You can check the remote file size
with:
print size? ftp://user:[pass--example--com]/pub/image.jpg
and you can check the file modification date with:
print modified? ftp://user:[pass--example--com]/pub/image.jpg
This level of Internet integration allows you to easily use network
resources throughout your programs.