[REBOL] Re: cgi question

2004-05-07 Thread Jones, Scott

From: Kai Peters
KP> You see me confused, for the script works well with 'my' formatting (am
KP> coming from C and Pascal and have always wanted my braces and begin/end 
KP> pairs lined up nicely). I thought I read somewhere that REBOL is very 
KP> lenient when it comes to white space etc. including CR/LF etc.?

From: Gregg Irwin
GI> Don't be confused, REBOL doesn't care at all about the formatting.
...

With all due respect, I am not a formatting elitist, either, and was not 
meaning to sound critical of Kai's formatting.  

In retrospect, the point I failed to make is that when cutting and pasting 
into a REBOL command line session, one can run into formatting issues.  
Here is an example from Kai's program, when a snippet is cut and pasted 
into a REBOL session (at least on Windows):

>> header: make system/standard/email
** Script Error: Invalid argument: (missing value)
** Near: header: make system/standard/email
>> [
[To:   [ recipient1 ]
[From: [ [EMAIL PROTECTED] ]
[Subject:  "subject"
[Organization: "organization"
[]
== [
To: [recipient1]
From: [EMAIL PROTECTED]
Subject: "subject"
Organization: "organization"
]

The same snippet runs without error when in a listing that is then run
as a program.  I frequently develop scripts by cutting and pasting 
from a text file into the command line.  I can get large code fragments 
loaded, so that I can then play with the results interactively. With
this method, at least on windows, REBOL *does* care about formatting.
As a result I tend to make sure that block arguments at least have the 
opening bracket start on the same line.

This is why I have so frequently warned of "watch for line wrap" when
responding to email on the list: cutting and pasting the fragment may
not work if the line received an "unfortunate" wrap location.

I *just* realized that I sort of assumed everyone developed using these
methods, and in that point I was being unfortunately narrow sighted.

I apologize!

With respect, best wishes to all!  Happy REBOLing however one wishes to 
format.

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: cgi question

2004-05-06 Thread Jones, Scott

From: Kai Peters
KP> I can send mail to the two obscured email addresses in the 
KP> script below from REBOL command w/o any problems. The 
KP> send/header  below however always fails. Anything obvious this 
KP> newbie might be doing wrong? How can I test what exactly the 
KP> problem is if not obvious to you gurus?
...

Hi, Kai,

I reached a little different conclusion than the others.  What struck 
me most was the *formatting* of your script.  When I ran you script
(using valid addresses of course), I confirmed errors after:
header: make system/standard/email
and after:
either error? try [ send/header reduce[ recipient1 recipient2 ] 
response header]

What puzzles me then is that you reported that fixes like removing "from" worked.  Did 
you change the formatting after that?

Said differently, when I changed the formatting such that the 
block start ("[") followed on the line (unfortunately, at least 
1 line will likely wrap):

REBOL []
response: "test"
recipient1:  [EMAIL PROTECTED]
recipient2:  [EMAIL PROTECTED]

header: make system/standard/email [
To:[recipient1 ]
From:[ [EMAIL PROTECTED] ]
Subject:"subject"
Organization:"organization"
]

either error? try [send/header reduce [recipient1 recipient2] response header][
web-response: { NOT ok! }
write/append %errorlog.txt response
][
web-response: { ok }
]
print web-response

It ran without error.  However, I think as may be suggested indirectly by others, you 
may wish to achieve a different effect, depending on your goals.  

Comments I would like to make include: In your code (with the formatting fixes), the 
"From" is only necessary if this designation is different from what is your REBOL 
default (found in user.r file).  I believe that the "To" may be setting what is 
supposed to be multiple email addresses to one (send looks to see if the "to" field is 
set).  If you try this reformatted version, but only one address receives the email, 
simply try leaving the "To:" field off the header, like:

header: make system/standard/email [
From:[ [EMAIL PROTECTED] ]
Subject:"subject"
Organization:"organization"
]

Again, "From" may not be necessary either.

I hope that my view does not confuse issues.  I just wanted to share that I "saw" a 
potentially different (and more basic) problem than the others in regards to the 
formatting.  If the formatting was actually changed by your client or through the 
email system, then my information may be of less use.  Does this make sense?

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: SMTP Authentication

2004-05-06 Thread Jones, Scott

From: Gabriele Santilli
SJ> I vaguely recall that TLS is an encoding or 
SJ> encrypting scheme.  Does anyone else know? 
...
GS> TLS is the Transport Layer Security protocol.
GS>
GS>http://www.ietf.org/rfc/rfc2246.txt

Thanks for confirming that, Gabriele.  I also found:
ftp://ftp.isi.edu/in-notes/rfc2487.txt
that explains more of the overview of smtp server behavior.

I did not have much time to explore the exim server information
on-line, but the information in the second RFC makes me wonder 
whether there may not be an alternative for your server.  Again, 
the server seems to "advertise" that it accepts plain 
authentication.  As I recall 3ish years ago, the extended smtp
(ESMTP) "standard" is not very standard at all, which was
reportedly why RT decided not to support it directly.  Indeed,
over the last several years we've seen several variations on
the list.  If you are interested in pursuing this with a non-
command REBOL, I would next communicate with your smtp server
through an interactive interface, most easily done through a 
telnet utility.  

SMTP servers will detect whether the client is on its net or not, 
and can require different logins based on this information.  Or
it can simply exclude connections from outside its network.  The
2nd RFC implies that if the smtp server is "publically exposed",
then it should not offer services on port 25 (the "usual" smtp
port) *if secured authentication is mandatory*.  A different port
(like 995, if I recall) is usually required.  This method allows
secured and authenticated transmission of emails from a client, but 
is *not* used as a relay mail transport.

Given that your email makes no reference to using any other port 
than the default, namely 25, then I am assuming that either the 
server is only accessible from within your network (subnet really)
or that it will allow an alternative login.  Otherwise, if my 
logic holds up, the server would be "noncompliant".  As I hinted, 
I wonder if the server may allow a plain authenticated login but 
through a somewhat nonstandard sequence of commands.  Hence the 
need to do some testing before deciding that it can't be done 
(easily) through "regular" REBOL.

Unfortunately, as I have made indirect reference to several times,
*describing* how to do this is not easy through an asynchronous
method like email.  When I helped Nick Carson out a few years ago
he gave me a temporary account on his server, so I could play
with the methods.

Before starting telnet, find out your client name at a utility
of your choice or with REBOL:
   probe system/network/host
>> probe system/network/host
"NSF00"

At any rate, use a telnet utility to communicate with the server
for an interactive session.  From the command line, it might
look something like:
telnet smtp.mydomain.com 25
or once in a telnet session it will more likely look like:
open smtp.mydomain.com 25
It the following the server lines are marked by "S>" and the
client lines are marked by "C>" (meaning, what you type in). Lines
will be wrapped on this email and will of course look different
with your server.  Some telnet utilities do not echo your input;
type especially carefully in those cases, or get a telnet utility
that does echo.

S> 220 apricot.southpole.usap.gov Microsoft ESMTP MAIL Service, 
  Version: 5.0.2195.6 713 ready at  Fri, 7 May 2004 08:08:56 +1200
C> HELO NSF00
S> 250 apricot.southpole.usap.gov Hello [157.132.6.107]
C> HELP
S> 214-This server supports the following commands:
S> 214 HELO EHLO STARTTLS RCPT DATA RSET MAIL QUIT HELP AUTH TURN 
   ATRN ETRN BDAT VRFY
C> QUIT
S> 221 2.0.0 apricot.southpole.usap.gov Service closing 
   transmission channel

In this simple sequence we have established basic communications with
the smtp server.  HELO is a standard log greeting typically used when
NO authentication is required.  The HELP command speaks for itself, and
will tell us what general commands are allowed.  Notice the EHLO command.
EHLO was added with the extended specification as a way of offering the
servers a way to allow logins with various levels of authentication.
You will notice that the patch I suggested substitutes this log greeting 
for HELO.

If this first session does not go well, it may be helpful to cut and
paste the information for the list to see.  Assuming the *does* go well,
next try the following at a telnet session:

S> 220 apricot.southpole.usap.gov Microsoft ESMTP MAIL Service, 
  Version: 5.0.2195.6 713 ready at  Fri, 7 May 2004 08:08:56 +1200
C> HELO NSF00
S> 250 apricot.southpole.usap.gov Hello [157.132.6.107]
C> AUTH PLAIN
...

(*BookMark 1*)
One of two things will likely happen.  The first will tell me that
the server is quirky in its authentication method (not following the
standard directly).  I can't tell you exactly what to look for but it
will likely either be a 334 code followed by either the text "Username:"
or the encoded text "VXNlcm5hbWU6" (which is "Username:" in base64

[REBOL] Re: SMTP Authentication

2004-05-05 Thread Jones, Scott

Hi, Stuart,

From: Stuart
...
> I hope I followed your directions properly.  
> Can you help me figure out what is wrong?
...

for rest of email, see:
http://www.rebol.net/list/list-msgs/35906.html

This is an interesting situation.  It appears as though you 
did everything correctly, assuming that "" was
substituted for "myusername", etc (meaning the angle
brackets were merely placed to help me see the substitution).

The traced output is very helpful, and yet I won't fully be 
able to do more research until our satellite that allows 
web access comes back up (hours from now).

In the meantime, here is what I see (this email will go out 
on our "slow" satellite):

The line:
Net-log: "250-AUTH PLAIN LOGIN"
suggests that a plain (clear) text login is appropriate for
this email server.  This is what you have done by manually
setting the username and password.

However, later, the line:
** User Error: Server error: tcp 501 Invalid base64 data
** Near: smtp-port: open [scheme: 'smtp]
would normally suggest that the server was expecting a base
64 encoded string.  You tried that last week, but you could 
try it again "to be sure".  Do exactly what you did but use
a direct encoding like as follows:
system/schemes/smtp/user: enbase/base "myusername" 64
system/schemes/smtp/pass: enbase/base "mypassword" 64
My guess is that this too will fail, like it apparently did 
last week.  Do it with the trace/net on to see if the message
is any different.  My guess is that it will not be 
significantly different.

I suspect that the major clue provided is with this line:
Net-log: "250-STARTTLS"
This is the most interesting point that I would like to 
research.  I vaguely recall that TLS is an encoding or 
encrypting scheme.  Does anyone else know?  If it is then
the email server may be looking for a "plain text" version 
of the encoded or encrypted username and password.  I do
not recall how this can be done easily through REBOL.  Does
anyone else know?

If no one else (that reads this email) has knowledge on
TLS, I would start by googling (meaning, use google.com to 
search) the exact string "250-STARTTLS"

Depending on what that yielded, I might next find out if
TLS is an encoding or encrypting scheme.

Depending on what that yielded, I would next find out more 
about the email server by googling "ESMTP Exim 4.24".  
Sometimes if an email server is not following a standard, there
will be 5 billion references on the net where people have
the same problem, and you can interpolate a REBOL solution
from the help these people receive.

Finally, as a cross check, I would google the line 
"tcp 501 Invalid base64 data" to be sure that this may not have 
an additional meaning besides what may be obvious.

If it ends up being that TLS is an encoding or encrypting
scheme, and if this method is not directly or easily supported 
in REBOL, then depending on the method used, you may be able
to do the encoding or encrypting *once* through some other utility
and then plug the results in directly into your scripts.

This is the best I can do without being able to access the web.
If I have time this evening, I will try to look.  In the 
meantime, I am hoping that either you or someone knows what
these clues mean, and can fill in the gap.

Hang in there.  You may get your REBOL solution yet.
--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: unwanted processes ...

2004-04-30 Thread Jones, Scott

From: Graham Chiu
> My ISP has again shut down my vanilla script, and rebol, 
> as there were 150 processes running :(
> 
> Anyone else having this problem.  They're running Solaris 
> sparq ... and I thought I was running latest core.
> 
> I had thought adding 'Quit to vanilla.r had solved the 
> problem.  Since most of these processes were most likely 
> spawned by bots crawling the site, I've now altered 
> .htaccess to exclude them all.  Bye bye googlebot! Hello, 
> anonymity :(

Hi, Graham,

I had not run across that sort of problem since the REBOL 2.0 and 2.1 era, so that 
does seem odd and interesting.

One idea that occurs to me is just a bit of extra control and logging.  I recall 
someone a year and a half ago showing how one gets the PID (process ID) from within 
REBOL (maybe Bo or Gregg???).  It was easy; I just can't remember it.  What if each 
time a script started up, it logged the time and its PID to a log file.  It also would 
read this log file and scan for PIDs that had been running for more than x amount of 
time and kill those.  It might keep you ISP happier if that could be made to work.  
Just a thought

For my own edification, I ask out of ignorance why a robot spawned script process 
would be left running and not a "legitimately" spawned one?  Is there some essential 
web property that I seem to be forgetting?

--Scott Jones
Weather for South Pole Station
The date is 05-01-2004 at 11:27 AM  
Temperature -64.7 C  -84.5 F
Windchill   -86.3 C  -123.3 F 
Wind 8.30 kts Grid 122
Barometer673.5 mb (10872. ft)
UTC 04-30-2004 at 23:27 Z
 

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: Parsing out strings

2004-04-29 Thread Jones, Scott

From: ML
...
> Suppose the line I am parsing says:
> "the user jsmith logged in at 4.30pm"
> 
> Can you give me a clue what I would use to 
> parse in each of these circumstances where 
> the desired text is:
> 
> 1. "the user"
> 2. "the user jsmith"
> 3. "jsmith"
> 4. "jsmith logged in at 4.30pm"
> 5. "logged in at 4.30pm"

Hi, Stuart,

You will get a hundred ways to do this.  In order to illustrate the more general 
principles, I offer the following ways (watch for line wrap).  The first is a bit 
"brute force":

data: "the user jsmith logged in at 4.30pm"
parse-bits: parse data none
probe rejoin [parse-bits/1 " " parse-bits/2]
probe rejoin [parse-bits/1 " " parse-bits/2 " " parse-bits/3]
probe parse-bits/3
probe rejoin [parse-bits/3 " " parse-bits/4 " " parse-bits/5 " " parse-bits/6 " " 
parse-bits/7]
probe rejoin [parse-bits/4 " " parse-bits/5 " " parse-bits/6 " " parse-bits/7]

This first method relies on the fact of the number of words of each record in the log 
remain the same.  The second method is more rule based, and it copies sections based 
on the rules:

data: "the user jsmith logged in at 4.30pm"
parse/all data [
copy p1 
thru "the user" 
copy p2 
to "logged" 
copy p3 
to end
]
trim p2
print [p1 p2 p3]

and finally a variation that demonstrates a slightly different way with more parse 
commands:

data: "the user jsmith logged in at 4.30pm"
parse/all data [
copy p1 
thru "the user" 
skip
copy p2 
to " "
skip
copy p3 
to end
]
print [p1 p2 p3]

Hope that helps get you started on the REBOL ways to parse.

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: SMTP Authentication

2004-04-29 Thread Jones, Scott

From: ML
> ...
> Sorry I didn't understand that the scripts were for SMTP 
> on MS Exchange only. I know my ISP is not using Exchange 
> servers, so do you think the scripts should still work, 
> or is there another way to pass username/password to non 
> Exchange SMTP servers?
...

Hi, Stuart,

It depends on whether your SMTP server follows the numeric prompt "334" and whether 
your SMTP server allows plain text authentication or some other method of encoding.  
This was why I suggested turning "trace/net on" and seeing what the net log says the 
server is asking.  

In the meantime you can still try the patch (watch for line wrap):

system/schemes/smtp/handler/open-check: [none "220" ["EHLO" system/network/host]  
"250" "AUTH LOGIN" "334" [port/user] "334" [port/pass] "235"]

Then try to have the user name and password sent as plain (unencoded) text.  Use this 
script fragment as one way to set these data:

view lo: layout [ 
text "username" 
f: field "username" [ 
system/schemes/smtp/user: copy value 
] 
text "password" 
field hide [ 
system/schemes/smtp/pass: copy value
unview/all 
] 
do [focus f] 
] 

or alternatively in noninteractive script method:
system/schemes/smtp/user: "myusername"
system/schemes/smtp/pass: "mypassword"

This fragment sets "system/schemes/smtp/user" to your username, and 
"system/schemes/smtp/pass" to your password.  Within the SMTP scheme 
"system/schemes/smtp/user" is represented by the internal path "port/user" and 
"system/schemes/smtp/pass" is represented by the internal path "port/pass".  So when 
the SMTP request is being handled and the numeric indicator "334" is detected, the 
protocol sends first the port/user, and then the port/pass is sent for the second 
"334".

If this suggestion does not work, then try at a *fresh* REBOL session turn the 
"trace/net on".  Then send a test email and make a copy of the net-log, obscuring any 
sensitive information and paste-ing that to the forum.  If I/we cannot figure it out 
from that, there is one other way (which I'll avoid explaining from now since I do not 
believe it will be necessary).

I hope the plain text authentication works.  If not let me/us know what the net log 
shows from a fresh REBOL session.

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: SMTP Authentication

2004-04-28 Thread Jones, Scott

Hi, Stuart,

> My SMTP server requires authentication with a username and 
> password before allowing mail to be sent.
> 
> I found esend.r and esmtp.r, installed those, ran them 
> individually as in the instructions and then tries to use 
> esend to send a mail.
> 
> It ran without an error, but never popped up anuthing to 
> ask me for a username and password to authenticate with.
>
>Anyone know what the problem is?

I wrote those patches several years ago.  I'm surprised that it ran without error, 
because more recent REBOLs less aggressively reduce certain information.

With the newer versions of REBOL, I have successfully used this newer patch with MS 
Exchange server(watch for line wrap):

system/schemes/smtp/handler/open-check: [none "220" ["EHLO" system/network/host]  
"250" "AUTH LOGIN" "334" [port/user] "334" [port/pass] "235"]

Then, I would throw the following view script in front of any script that used 
Exchange email.  Note that the script encodes the username and password in base 64, 
which is required by MS Exchange Server. You may of course replace "MSusername" with 
the default that you would like presented.  Hitting return key advances the field and 
does final entry.

view lo: layout [ 
text "username" 
f: field "MSusername" [ 
system/schemes/smtp/user: copy enbase/base value 64 
] 
text "password" 
field hide [ 
system/schemes/smtp/pass: copy enbase/base value 64 
unview/all 
] 
do [focus f] 
] 

Then, you should be able to use the regular REBOL send command for email.

Without knowing which email smtp server to which you are connecting, it is impossible 
to know how to encode the authentication information.  I would try this method first, 
especially if it is an MS Exchange server.  If it does not work, next try the:
trace/net on
command and then send a test email and capture the output.  Generally, right before 
the authentication is sent the server indicates what form of authentication and 
encoding may be required.  Obscuring any sensitive information, you can report that 
back here, and I or someone may be able to direct you how to change the patch.  If 
that fails to capture the information, there is yet another way to figure this out 
that I can explain more fully.

Best wishes

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: Silenceing the double equal

2004-04-28 Thread Jones, Scott

From: paul porter
Is it possible to turn of the "=="? I've tried loading rebol with "./rebol
-q", and "./rebol --quite"; neither one seems to do the trick.

An input will be greatly appreciated.



Hi, Paul,

What you seek can be found under the console prompts:

>> probe system/console

make object! [
history: ["probe system/console"]
keys: none
prompt: ">> "
result: "== "
escape: "(escape)"
busy: "|/-\"
tab-size: 4
break: true
]

>> probe system/console/result
"== "
== "== "
>> system/console/result: ""
""
>> d: 1
1

Hope that helps.

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: [context] How to compose in a local context

2004-04-21 Thread Jones, Scott

From: Ashley TrĂ¼ter
Given the following:

>> b: 'a
== a
>> do has [a][set 'a 0]
== 0
>> a
** Script Error: a has no value
** Near: a
>> do has [a][do compose/deep [set [(b)] 0]]
== 0
>> a
== 0

How can I prevent 'compose from binding to the global context?


Hi, Ashley,

I'm not an expert on binding, but as you seem to be aware, it appears as though the 
order of evaluation has 'a being set to 0 in the global context by way of the 'do 
command *inside* the block.  An alternative approach is to "compose" the full line:

b: 'a
do compose/deep [has [a][set (to-lit-word b) 0]]

The actual lines I used in order to be sure that I had it right was:

b: 'a
do compose/deep [
c: has [a][
set (to-lit-word b) 0 
print (b)
]
]

such that:

>> do compose/deep [
[c: has [a][
[set (to-lit-word b) 0
[print (b)
[]
[]
>> c
0
>> a
** Script Error: a has no value
** Near: a
>> b
== a
>>

Finally, if you want to get the function ready but not run it, then:

b: 'a
reduce compose/deep [
c: has [a][
set (to-lit-word b) 0 
print (b)
]
]

Hope that helps.

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: Problem reading url

2004-04-18 Thread Jones, Scott

Raimund,

REBOL generally follows the accepted standard for url characters; however, frequently 
websites use characters that are not technically part of the standard.  I have not 
checked for "^".

At any rate the net-utils parsing rules *sometimes* can be patched to allow the url to 
be parsed.  I have tried the patch for this character and it appears to parse, but I 
do not know if it retrieves the information for which you seek.  Watch for line wrap.

net-utils/url-parser/path-char: union net-utils/url-parser/path-char make bitset! "^^"
read http://de.finance.yahoo.com/d/quotes/csv?s=^GDAXI&f=sl1t1d1c1pohgv

yields:
connecting to: de.finance.yahoo.com
== {^^GDAXI;4033,98;17:45;4/16/2004;+29,37;4004,61;4004,61;4043,53;3986,62;0
}

This patch may make other tcp accesses unstable, so use at your own risk, or 
alternatively:

old-bitset: copy net-utils/url-parser/path-char
net-utils/url-parser/path-char: union net-utils/url-parser/path-char make bitset! "^^"
read http://de.finance.yahoo.com/d/quotes/csv?s=^GDAXI&f=sl1t1d1c1pohgv
net-utils/url-parser/path-char: copy old-bitset

which then reverts the bitset back to the original.

Hope that this helps as an alternative to Anton's more properly formatted method.

--Scott Jones

-Original Message-
From: Anton Rolls 

Just having a look in net-utils/url-parser ...
write clipboard:// mold net-utils/url-parser


Just used this tool:

http://www.w3schools.com/html/html_ref_urlencode.asp

which encodes your url thus:

http%3A%2F%2Fde%2Efinance%2Eyahoo%2Ecom%2Fd%2Fquotes%2Fcsv%3Fs%3D%5EGDAXI%26
f%3Dsl1t1d1c1pohgv%0D%0A

Notice the %3D%5E, which looks like the encoding for ^
If I replace the ^ with %3D%5E, then I can read the url ok.

Not sure what this means for rebol's url-parser.

Anton.

> Hi,
>
> I try to read an URL which contains an ^. But this always fails:
>
> >> URL: to-url {http://de.finance.yahoo.com/d/quotes/
> csv?s=^GDAXI&f=sl1t1d1c1pohgv}
> == http://de.finance.yahoo.com/d/quotes/csv?s=%07DAXI&f=sl1t1d1c1pohgv
> >> read URL
> ** User Error: URL error: http://de.finance.yahoo.com/d/quotes/
> csv?s=DAXI&f=sl1t1d1c1pohgv
> ** Near: read URL
> >>
>
> Omitting the "^" works but is obviously not the correct URL. Is
> this a bug or
> a feature?
>
> Raimund

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.


-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: set-net crash with unusual account name

2004-04-18 Thread Jones, Scott

Hi, Bry,

As you might have noticed in a separate thread, REBOL generally correctly parses 
correctly formed URL's but not all websites seem to conform to the standard.  The 
net-utils parsing rules *sometimes* can be patched to allow the url to be parsed.  I 
have tried the patch for this character and it appears to parse.  Watch for line wrap.

net-utils/url-parser/user-char: union net-utils/url-parser/user-char make bitset! "\"

such that

a: read pop://user\domain:[EMAIL PROTECTED]

yields user of "user\domain"
and password of "password"

An alternative is mentioned in the other email that I sent, namely, directly set the 
user name in the POP protocol.

Hope this helps!

--Scott Jones

-Original Message-
From: bry

Hi,
my email server seems to have unusual 
account names, these being in the form of 
name \ domain instead of [EMAIL PROTECTED]

I also need to have set-net have my login.

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: how do i use set-net to tell my email server what my password is?

2004-04-18 Thread Jones, Scott

From: bry
> how do i use set-net to tell my email server what my password is?

The set-net function does not directly support this option; however, one can add a 
line to the user.r file or script which directly inserts the password into the pop 
protocol:

system/schemes/pop/pass: "my-password"

Note that this does represent some security risk, so this information should only be 
accessible to the script, and not to a web browser.  Also note that the username name 
can also be set as such:

system/schemes/pop/user: "my-user-name"

and then mail read via:

mail-data: read pop://pop3.mydomain.dom

Hope this helps.

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: Newbie Rebol (CGI) questions - correction

2004-04-16 Thread Jones, Scott

Forgot the 'try command:


header: make system/standard/email [
To: [EMAIL PROTECTED]
From: [EMAIL PROTECTED]
Subject: "Message with a header"
Organization: "Super Org"
]
either error? try [send/header [EMAIL PROTECTED] response header][
web-response: {There has been an error in processing your
information.  While the error has been logged, you may wish to
resubmit this information if you have not heard back within 48 hours.}
write/append %/path/to/web/error/log/log.txt response
][
web-response: {Thank you for submitting this information.  
Your response will be processed, and you should receive
an answer within 48 hours.}
]
print web-response


--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: Newbie Rebol (CGI) questions

2004-04-16 Thread Jones, Scott

Hi, Kai,

From: Kai Peters
KP> From the web tutorials I have doctored the script below 
KP> together which leaves me with three questions:

KP> 1) Why do I receive an error if i omit the print line 
KP> immediately after the REBOL [] header?

The web HTTP protocol requires that the web server return a designation for the type 
of content that is to be sent, and that this designation shall be followed by a blank 
line before any content is actually sent.  The CGI script may be designed to handle 
form input, but in a way of speaking, its "responsibility" is to return something to 
the browser.  Hence the "Content-type: text/html" which is the usual html web type.  
As an aside, notice that this line ends with a escaped newline character "^/".  The 
print command supplies one newline and a second must be supplied inorder for there the 
be a "blank line" following this line.

KP> 2)  How can I insert LFs in the line
KP> " emit [ mold var  mold value ]" 
KP> to make the mail more readable?

This "emit" function is one of the language designer's favorite methods for forming 
large strings from static text, variables, etc.  However, I suspect it may be causing 
confusion for you where the answer might otherwise be obvious.  Using a more linear 
method makes it more obvious how to manage the formatting of strings:

;create a decent size string in order to save 
;   time having to "grow" it later
response: make string! 2000 
; skip code for brevity
;...
foreach [var value] decode-cgi read-cgi [
append response var
append response "="
append response value
append response newline
   ]

which can be shortened to:

response: make string! 2000 
;...
foreach [var value] decode-cgi read-cgi [
append response reduce [var "=" value newline]
]

Since the variables are in a block, REBOL needs to know to substitute their values, 
which is the purpose of the 'reduce command.  This can be further shortened to:

response: make string! 2000 
;...
foreach [var value] decode-cgi read-cgi [
repend response [var "=" value newline]
]

in which the "reduction" occurs within the repend command.  At this juncture, you will 
more readily recognize the emit function.

KP> 3) How can i do the set-net stuff permanently?

Place a user.r file with the requisite 'set-net command in the executable directory.  
This essentially just reads the same exact command in before presenting REBOL's 
command line.

By the way, before sending your email through the CGI interface, you may wish to add 
two things.  First add a first line that will then become the subject for the email 
message, like:
response: rejoin ["[somedom.com form] sent: " now newline response]
This makes it easy to spot mail that comes from your website form system.  Second, 
send the user some feedback that the information was taken and that they can expect a 
response back, like:

header: make system/standard/email [
To: [EMAIL PROTECTED]
From: [EMAIL PROTECTED]
Subject: "Message with a header"
Organization: "Super Org"
]
either error? [send/header [EMAIL PROTECTED] response header][
web-response: {There has been an error in processing your
information.  While the error has been logged, you may wish to
resubmit this information if you have not heard back within 48 hours.}
write/append %/path/to/web/error/log/log.txt response
][
web-response: {Thank you for submitting this information.  
Your response will be processed, and you should receive
an answer within 48 hours.}
]
print web-response

Hope this helps demystify the REBOL way of managing CGI form data.
--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: hook while downloading from html port

2004-04-15 Thread Jones, Scott

From: Anton Rolls
AR> Scott, I think you are a bit negative about transfer rates. :)
AR> Surely there is a way.
...

It was one of those things were as soon as I sent my email, I, too, thought of a way 
to show progress, but our satellite signals times are limited.  My guess is that there 
will already be 3 more ways to do it by the time this arrives!

Not unlike Anton's way in using read, I capture the actual bytes read from the return 
of read-io and accumulate these in a variable.  If the site provides content length, 
then the patch can compare sent to expected.  Unfortunately, not all servers/websites 
send the content length.  

At the end of the http scheme, and the variable "bytes-transferred", as in:
   ...
cache-size: 5
user-agent: "REBOL View 1.2.10.3.1"
bytes-transferred: 0
]

Then change the read function to (watch for line wrap):

read: func [
port "An open port spec" 
data "A buffer to use for the read"
/local bytes-read
][
net-utils/net-log ["low level read of " port/state/num "bytes"]
bytes-read: read-io port/sub-port data port/state/num
bytes-transferred: bytes-transferred + bytes-read
if port/locals/headers/content-length <> none [print [to-integer 
(bytes-transferred / (to-integer port/locals/headers/content-length) * 100) "percent"]]
bytes-read
]

Reading a page in which the server gives content-length will allow the calculation of 
percent received.  I realized that the read function needs to return the bytes, read, 
hence the last line.

Expanding on the idea, I decided for fun to try to create a visual feedback method 
that gives progress bar when the content-length is known, or simple accumulated bytes 
retrieved, when content-length was unknown.  It requires a fair amount of patching.

Starting with a fresh copy of the http scheme, one first alters the continue-post 
function:

continue-post: func [/tunnel] [
response-line: system/words/pick port/sub-port 1 
net-utils/net-log response-line 
either none? response-line [do error] [
either none? result: select either tunnel [tunnel-actions] [response-actions] 
response-code: to-integer second parse response-line none [do error] [do get 
result]
]
if show-progress [
either port/locals/headers/content-length <> none [
progress-message/pane: layout/origin/offset [p: progress] 0x0 0x0 
show progress-message
][
progress-message/pane: layout/origin/offset [t: text 200x16] 0x0 0x0  
show progress-message
]
]
] 

Then following the close block and build-port further down, one inserts these lines
...
] 
build-port ;insert following lines
if all [block? port/state/custom post-data: find port/state/custom to-lit-word 
'progress block? post-data] [
show-progress: true
progress-message: get to-word select port/state/custom to-lit-word 'progress
]

Then one changes the close function:

close: func [port][
if show-progress [
progress-message/pane: layout/origin/offset [t: text 200x16] 0x0 0x0  
show progress-message
t/text: "Done!"
show t
show-progress: none
]
system/words/close port/sub-port
bytes-transferred: 0
]

One changes the read function:

read: func [
port "An open port spec" 
data "A buffer to use for the read"
/local bytes-read
][
net-utils/net-log ["low level read of " port/state/num "bytes"]
bytes-read: read-io port/sub-port data port/state/num
bytes-transferred: bytes-transferred + bytes-read
if show-progress [
either port/locals/headers/content-length <> none [
p/data: bytes-transferred / (to-integer port/locals/headers/content-length)
show p
;loop 1000 [] ;uncomment to see fast pages load
][
t/text: bytes-transferred
show t
;loop 1000 []
]
]
bytes-read
]

Finally, one adds variables to the end of the scheme:

user-agent: "REBOL View 1.2.10.3.1"
bytes-transferred: 0
show-progress: progress-message: p: t: none
]

One uses the custom refinement to pass the reference to a VID box:

view layout [
f: field 300x24
button "Get Page" [
read/custom trim to-url f/text ['progress :my-pane]
]
my-pane: box 200x16
button "Exit" [quit]
]

When one types in a url from a website where the server gives the content-length, the 
box gets a progress bar embedded, which is then updated based on the percentage of 
bytes read.  When the url is served from a server that does not give the 
content-length, then the bytes retrieved are displayed.  After completed, the progress 
box is converted to text that says "Done!"  I have commented out some do nothing loops 
in case your downloads are too fast, and you are trying to see the changes at work.  

I was just about to send thi

[REBOL] Re: hook while downloading from html port

2004-04-14 Thread Jones, Scott

From: Maxim Olivier-Adlhoch
...
I was wondering, if its possible to put a hook somewhere (even if deep) within
the port or more specifically the html port handler, so that we can update
something elsewhere, do statistics or print out transfer rate for example...
...


Hi, Max,

Since no one has offered anything any more specific, I can suggest a general way to 
put in your own hooks, but some of the services are at a lower level than you can 
access through the standard service.

First, you'll need a working copy of the scheme.  For example, for http:

echo %/path/to/my-http.txt
probe system/schemes/http
echo off

With this text file, first place:
system/schemes/http: 
near the top before the make, like:
system/schemes/http: make object! [
scheme: 'HTTP
host: none
port-id: 80
...

Then go to the end of the file and erase everything after the last "]" and resave the 
file.  This file can be loaded in as a replacement for the http scheme.  If reloaded 
as such, there will be no change.

Now, you have to begin to understand how the schemes work.  As the port for a scheme 
is read, it goes through these stages (or functions):
init
open-proto
open
close
The lowest level functions, accessed more "invisibly," are read and write.

By playing with probe or print statements and then accessing a web page, one can begin 
to get more information at a stage of the process as needed.  You will find after a 
lot of experimentation that much of the reading is done at a very low level, like 
through 'read-io.  This function stores its data in temporary spaces in this protocol, 
like the port/state object that is used during the access.  If you try to access these 
data, you inadvertently end up botching the operation, so care must be used and there 
are definitely limits to what can be used.  The only way to bypass some of the limits 
would be to extensively modify the scheme, which can be done with some work and care, 
or to create your own, which is reinventing the wheel.

It may be enough to get you going, but I would not be overenthusiastic about thinking 
you will be able the scrounge things like transfer rates!

Hope this gives you some help.

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: differences between script output and typing with tcp port

2004-04-05 Thread Jones, Scott

===
On 5 Apr 2004 at 23:06, Anton Rolls wrote:

I think don't use /no-wait.
(You also might not need to use wait myPop, then ...)
Just a quick suggestion.
The difference between console typing session and
script is: the script doesn't pause in between...

===

From: Janeks

I experimented with wait / nowait - it is not a 
reason. 
...

===

Hi, Janeks,

I think you may not have fully understood what Anton was suggesting.  I can't speak 
for Anton, but I suspect that he was meaning that you may not have picked the ideal 
*combination* of commands for use.  Rewritten in a slightly different way:

***
print "Content-Type: text/plain"
print ""  ; required
print ""
print ""
print "Rebol script test"
print ""
print ""
print "Hello!"

checkPop: func [user-name passe pop-server port-number] [
myCommands: ["user admin" "pass qwerty" "list"]
myPop: open/lines [
scheme: 'tcp
host: pop-server
port-id: port-number
]
response: pick myPop 1
probe response
print ""

foreach myCom myCommands [
print join ">" myCom
print ""
insert myPop myCom
either mycom <> "list" [
response: pick myPop 1
probe response
][
while [(response: pick mypop 1) <> "."] [probe response]
]
]

print ""

print "quit"
insert myPop "quit"
probe pick myPop 1
print ""

close myPop
]

checkPop "admin" "qwerty" "localhost" 110

print ""
print ""


In this version, the tcp open command reads by line but waits for the line.  The pick 
command picks the "first" response that comes in on the port, namely the first line.  
The main "problem" that comes in are the multiline responses.  In this case I borrowed 
the technique used in the REBOL's POP scheme, namely read until an end marker is 
detected. I left your program in the same form so that you can compare and contrast 
what I think Anton meant with your own version.  

It is fun to play with the TCP protocols as you have.  For a better understanding of 
master REBOL techniques, try reading through the REBOL POP scheme:

probe system/schemes/pop

and its companion support utilities:

probe net-utils

Hope that helps on ALL your platforms.

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: newbie q : value & label in text-lists

2004-03-30 Thread Jones, Scott

Hi, "brds Janek",
...
> I would like to set up text-list in my layout, so it 
> shows just labels, but when selected I could get 
> value.
...

I suspect that there are several ways.  Here is one:

data: ["Label 1" "Value 1" "Label 2" "Value 2"]
labels: copy []
foreach [label value] data [append labels label]
view layout [
text-list data labels [
t/text: copy select data value
show t
]
t: text 200x24
]

--Scott Jones

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.



[REBOL] Re: Sending mails & authentification

2004-03-30 Thread Jones, Scott

 Re: Sending mails & authentification

Hi, Robert, 

I'm down at the south pole, and we've had satellite problem that has made it very 
difficult to keep up with the list.  I just happened to check the discussion list and  
noticed your problem.

The REBOL interpreter used to be more aggressive in its evaluation of expressions, and 
my 2001 esend and esmtp took advantage of the evaluation.  The newer versions of REBOL 
over the last couple of years are less aggressive, so last year I change the patch and 
found an easier way to apply it.  This patch is looks for the authentication requests 
and feeds the username and password, when appropriate:

system/schemes/smtp/handler/open-check: [none "220" ["EHLO" system/network/host]  
"250" "AUTH LOGIN" "334" [port/user] "334" [port/pass] "235"]

Then, I would throw the following view script in front of any script that used 
Exchange email.  Note that the script encodes the username and password in base 64, 
which is required by MS Exchange Server. You may of course replace "MSusername" with 
the default that you would like presented.  Hitting return key advances the field and 
does final entry.

view lo: layout [ 
text "username" 
f: field "MSusername" [ 
system/schemes/smtp/user: copy enbase/base value 64 
] 
text "password" 
field hide [ 
system/schemes/smtp/pass: copy enbase/base value 64 
unview/all 
] 
do [focus f] 
] 

Then, you should be able to use the regular send command for email.  With luck, this 
method will still work for MS Exchange (5.5 at least).

HOWEVER, it appears as though your smtp server may want a *plain* authentication, 
meaning no encoding.  If so, then you may wish to try:

view lo: layout [ 
text "username" 
f: field "username" [ 
system/schemes/smtp/user: copy value 
] 
text "password" 
field hide [ 
system/schemes/smtp/pass: copy value 
unview/all 
] 
do [focus f] 
] 

This version passes the unencoded versions of the username and password. 

Hope that this helps. 

--Scott Jones 
 

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.