Hi gang,

... some three weeks ago our Inet admins changed topology of our
network, slowing down connection to firewall significantly. It's not
problem for web browsing, but as we have to use socks hosts setting
we've got problem on stations using Netscape. Time to solve the
situation ...

After scanning netscape newsgroups, I found some reference to page,
where various hints were described. And, 1 hour after mindight I finally
found the solution.

The solution was based on placing one file, socks.cnf somewhere on
harddrive, containing just two lines:

direct  127.0.0.1       255.0.0.0
direct  194.196.82.0   255.255.255.0

But, reference to this file has to be made inside prefs.js,:

user_pref("browser.socksfile_location", "C:\\socks.cnf");

I choosed C:\\ directory, as I can't be sure where even Windows
directory on entire system is placed.

It was nightmare to think I will have to visit all my Netscape users
.... Some of them had also bad IP email server representation, so time
to correct situation?

REBOL story
--------------

Of course, REBOL came to my mind. I decide to put rebol executable on
shared F: network drive, into shared directory, prepared list of our
company Internet users, and with just two lines of code I distributed
message:

(first thanks to replace/all I replaced all occurences of old domain
@trz.cz with new one - @moravia-steel.cz, and wrote file back to hd)

do %ms-emails ; contains block of email messages
send ms-email read %announce.txt

I then created new folder in my Netscape, called FASTMAIL and completed
filter, to get incomming responses into mentioned directory ....

Now the script.....

Yesterday my script looked completly different. It was top down
mechanism of various activities - look for the file, load something,
check something, write something, what a mess ...

I can't know how about you, but I personally like 'foreach function
mechanism. And as I came home, I decided to "sculpt" my script by
putting the old one in the trashcan, getting just pieces of it, but
ordering it in the completly different manner. I decided to create a
small dialect.

I was so amazed, I am not used my programs work merely at first try. My
script worked and did a great job for me, heh, still is doing, as I am
starting to receive messages from my users, some of them are calling me
"Hey, how can I get to F://vymena/netscape/fastmail", not even knowing,
how to properly use Windows.

Ah, as for dialect, when I tried to do something with my script, and
wanting to avoid calling of some part of code, I just commented one line
of code.

REBOL is so great and there is always more then several ways how to do
things ...... My thanks go to REBOL Tech folks :-))

----------------------------------------------------------------------------------------------

I know true rebol masters would write the following script much better,
nicer, but that's simply how I did it ... :-)
I thought about putting the script as an example to rebol.org script
database, but it's so of special purpose, I am not sure it could be of
any use. Anyone?
----------------------------------------------------------------------------------------------

REBOL [

Title: "How to speed-up Netscape email downloading ...."
Author: "Petr Krenzelok"
Email:  [EMAIL PROTECTED]
Date:   3-Nov-1999

]



find-on-path: func [{Find file on given path ... (end dir entries with
"/")}
                     path
                     file
                     /subdirs
                       "Scan also subdirectories ...."
                     /local dir-list reduced-dir-list
                  ][


     dir-list: copy []
     dir-list: read path

     either found? find dir-list file [
             return path
     ][

       either not subdirs [return none][

           reduced-dir-list: copy []  ; let's reduce dir-list to contain
directories only ...
           foreach dir-or-file dir-list [if (last to-string dir-or-file)
= #"/" [insert reduced-dir-list dir-or-file]]

            dir-list: copy reduced-dir-list
            reduced-dir-list: copy []

           foreach dir dir-list [
             result: find-on-path/subdirs join path dir file
               if not none? result [return result]
           ] return none

     ]

    ]

]

;-----------------------------------------------------------------------------------

;    TASK DIALECT
;-----------------------------------------------------------------------------------



task-dialect: [

"Perform initialisation"
;-----------------------

[

   happened: make block! 0
   Prefs-js-dir: none
   User-dir: none
]


"Welcome user"
;-------------

[
   print newline
   print trim {

              Ahoj �lov��e, tak bys r�d rychleji dost�val mail�ky? :-)
OK, zkus�me to ...
              Nejprve prohled�m Tv�j po��ta�, abych zjistil, kde je
Netscape nainstalov�n ...


-------------------------------------------------------------------------------}

]



"Ask for user info"
;------------------

[
   name: ask "Zadejte pros�m Va�e jm�no a p��jmen�: "
   tel:   ask "Zadejte pros�m Va�e telefonn� ��slo: "
   print newline

   Insert tail happened reduce ["Jm�no: " name newline "Telefon: " tel
newline]

]



"Try to find Netscape's prefs.js"
;--------------------------------

[

   possible-vols: [%/C/ %/D/]

   foreach vol possible-vols [

     print ["Prohled�v�m disk" second to-string vol]
      Prefs-js-dir: find-on-path/subdirs vol %prefs.js
        if not none? Prefs-js-dir [
             print ["Nalezl jsem pot�ebn� konfigura�n� soubor Netscape
na cest�" Prefs-js-dir newline]
             break
        ]

   ]

   either none? Prefs-js-dir [
        Insert tail happened reduce ["Cesta: Konfigura�n� soubor
Netscape prefs.js nenalezen" newline]
   ][
        Insert tail happened reduce ["Cesta: " to-string Prefs-js-dir
newline]
   ]

]



"Check for multiple user profiles"
;--------------------------------

[
   if not none? Prefs-js-dir [

      either error? try [User-dir:  read Prefs-js-dir/../../Users/.][
          Insert tail happened reduce ["Verze 4.x?: Ne" newline]
          print ["Nalezen� verze Netscape je star�� ne� 4.x, volejte
37339 (Petr Kren�elok)" newline]
      ][
          Insert tail happened reduce ["Verze 4.x?: Ano" newline]
          print ["Kontrola verze �sp�n�, prob�h� p��prava k aktualizaci
..." newline]
      ]

   ]

]


"Perform updates"
;---------------

[

   if not none? Prefs-js-dir [

        if not none? User-dir [

               speed-up: {user_pref("browser.socksfile_location",
"C:\\socks.cnf");}

               foreach user-profile User-dir [

                  tmp: read
Prefs-js-dir/../../Users/:user-profile/prefs.js
                  replace/all tmp "194.196.81.135" "194.196.82.135"
                  append tail tmp "^/"
                  append tail tmp speed-up
                  write Prefs-js-dir/../../Users/:user-profile/prefs.js
tmp
                  write %/C/socks.cnf read
%/F/vymena/Netscape/FastMail/socks.cnf

                  Insert tail happened reduce ["Profil: " User-profile
"aktualizovan ..." newline]
                  print ["Profil " User-profile "aktualizov�n ..."
newline]

              ]
       ]

   ]

]


"Send result notification"
;-------------------------

[

   header: make object! [

          From:       [EMAIL PROTECTED]
          To:         [EMAIL PROTECTED]
          Date:       now
          Subject:    reform ["[FASTMAIL]" name "  tel: " tel]


   ]

   print "Odes�l�m informace o �sp�chu/ne�sp�chu aktualizace Petru
Kren�elokovi ..."
   print "Pros�m �ekejte, program se s�m ukon�� ..."

   send/header [EMAIL PROTECTED] reform happened header


]


"Quit"
;-----

[

   quit

]


]


tasks: [

"Perform initialisation"
"Welcome user"
"Ask For user Info"
"Try to find Netscape's prefs.js"
"Check for multiple user profiles"
"Perform updates"
"Send result notification"
"Quit"

]



foreach task tasks [do select task-dialect task]

Reply via email to