• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Firefox D&D install !!!

Started by sXwamp, 2011.12.04, 05:43:42

Previous topic - Next topic

sXwamp

 
I need help with this Rexx install script for Firefox. I got sick of installing Firefox manually, so I wrote this script. Just drop any Firefox zip file on the object and it automatically unzips it and installs firefox. It's still pretty ugly, but it works for me !

http://www.os2notes.com/os2firefoxdd.html




Also, for the Rexx programming guru's out there, can someone tell me how to parse the name from 'firefox-8.0.1.en-US.os2' to 'Firefox-8.0.1' for the name of the installation directory.

And I need a way to delete all the files and directories in a firefox directory, except 'firefox.exe', 'firefox!K.exe', and 'firefox.ico' using a Rexx script.

Greggory


ivan

Hi Greggory,

Have you had a look at Lars Erdmann's installer script on hobbes?  It might help you d what you want.

ivan

RobertM

Quote from: sXwamp on 2011.12.04, 05:43:42
Also, for the Rexx programming guru's out there, can someone tell me how to parse the name from 'firefox-8.0.1.en-US.os2' to 'Firefox-8.0.1' for the name of the installation directory.

Hi Greggory, assuming the naming convention is the same for each new one, it would be:

/* (assign file name to a var, such as fName for this example - using "Parse Arg" probably) */
Parse Var fName with fDir".en-US"JunkVar


And that's it! fDir now contains the directory up to but not including everything from ".en-US" onwards.

Now, if the file name variable (fName) contains the directory as well, there are multiple ways of "stripping" that out. Again, assuming a standardized naming convention, the script would look something like this:

/* (assign file name to a var, such as fName for this example - using "Parse Arg" probably) */
Parse Var fName with JunkVar1"firefox-"fDir".en-US"JunkVar2
fDir="firefox-"||fDir


Of course, you still need to append the actual base path/drive letter to the variable for the install... but that's easy.



Quote from: sXwamp on 2011.12.04, 05:43:42
And I need a way to delete all the files and directories in a firefox directory, except 'firefox.exe', 'firefox!K.exe', and 'firefox.ico' using a Rexx script.

Greggory

This is a little tiny bit more complex. But not too much more complex. Here's the simple but slower (runtime-wise) method:
First, build a directory tree of that sub-directory, then step through it. Delete all files that don't match those values.

/* Some script or function call - fDir assumed to be directory of Firefox and its sub-directories */
/* fDir is assumed to have NO trailing slash... ie: it should look like "f:\Apps\Firefox" - and NOT like "f:\Apps\Firefox\" */

/* Create Match list of do-not-deletes */
    NoDel.1='firefox.exe'
    NoDel.2='firefox!K.exe'
    NoDel.3='firefox.ico'
    NoDel.0=3  /* Set stem array length */


/* Read directory and all sub-directories and create file list in stem array filelist. */
/* We only care about the fully qualified path names, so use "O" option to drop dates, times, attribs, etc */
    rtc=SysFileTree(fDir||"\*","filelist","SO",)   

/* Create worker loops */
    Do A=1 to filelist.0    /* Loop through file list using count in stem base */
        /* Set delete flag to "Y"(es) */
        delfile="Y"
        Do B=1 to NoDel.0    /* Compare to each value in NoDel array */
            if Pos(Translate(NoDel.B),Translate(filelist.A))>0 then   /* found a match - using upper case to ensure proper matching */
            Do
                delfile="N"    /* Do NOT delete file */
                Leave         /* We can leave the inner loop and return to the "Do A" loop */
            End
        End
        if delfile="Y" then
        Do             /* unneeded Do/End pair, but neater and easier to read */
            rtc=SysFileDelete(filelist.B)    /* delete file */
            /* Add programming code here to check error codes if wanted - for instance cant delete because locked file */
        End
    End



That should do it... a bit sloppily perhaps, but it will work very well.

Best,
Rob


|
|
Kirk's 5 Year Mission Continues at:
Star Trek New Voyages
|
|


sXwamp

#3
Hi Robert,

Perfect thanks, someone else sent me the first part on how to format the name.  But I was having issues on the second part -- now I'm all set. Guess I should add Thunderbird and Seamonkey to the list too !!!

Cheers,

Greggory

sXwamp

Quote from: ivan on 2011.12.04, 18:18:51
Hi Greggory,

Have you had a look at Lars Erdmann's installer script on hobbes?  It might help you d what you want.

ivan

Thanks, yes I'm going to see if he'll add this to his code or add his to my script.

Greggory

jep

#5
Quote from: sXwamp on 2011.12.04, 05:43:42
Also, for the Rexx programming guru's out there, can someone tell me how to parse the name from 'firefox-8.0.1.en-US.os2' to 'Firefox-8.0.1' for the name of the installation directory.

PARSE VALUE FILESPEC( full_path_name, 'N' ) WITH ff_name'.en-'.

Quote from: sXwamp on 2011.12.04, 05:43:42
And I need a way to delete all the files and directories in a firefox directory, except 'firefox.exe', 'firefox!K.exe', and 'firefox.ico' using a Rexx script.

Greggory

A shortend version of the code RobertM provided.
/* List files and delete each of them */

/* Create Match list of do-not-deletes, upper case! */
   NoDel.1='FIREFOX.EXE'
   NoDel.2='FIREFOX!K.EXE'
   NoDel.3='FIREFOX.ICO'
   NoDel.0=3  /* Set stem array length */

/* Read directory and all sub-directories and create file list in stem array filelist, take care of possible trailing back slash */
/* We only care about the fully qualified path names and in subfolders as well, so use "O" option to drop dates, times, attribs, etc */
   rtc = SysFileTree( STRIP( fDir, 'T', '\' )||"\*", "filelist", "SFO" )  

/* Create worker loops */
   Do A = 1 to filelist.0    /* Loop through file list using count in stem base */
       Do B = 1 to NoDel.0    /* Compare to each value in NoDel array */
           If Pos( NoDel.B, Translate( filelist.A ) ) > 0 Then   /* found a match - using upper case to ensure proper matching */
           Iterate A /* Jump to the next file in the list and don't process this one! */
       End
       rtc = SysFileDelete( filelist.A /* corrected from B to A */ )    /* delete file */
       /* Add programming code here to check error codes if wanted - for instance cant delete because locked file */
/*        If rtc = 0 Then Say FileSpec( filelist.A, 'N' ) 'deleted' */
   End


Another way to do this:
           If Pos( NoDel.B, Translate( filelist.A ) ) > 0 Then   /* found a match - using upper case to ensure proper matching */

is to write
           If NoDel.B = Translate( FileSpec( filelist.A, 'N' ) ) Then
which will match files with the whole file name (no path) so that we don't get a positive match with
nofirefox.exe that we'd get with Pos( ... )

Compare this example:
filelist.A = 'C:\path\Firefox-8.0.1\nofirefox.exe'

Pos( NoDel.B, Translate( filelist.A ) ) > 0 ---> POS( FIREFOX.EXE, C:\PATH\FIREFOX-8.0.1\NOFIREFOX.EXE ) >0 that is 24 > 0 which equals TRUE
while the comparison
NoDel.B = Translate( FileSpec( filelist.A, 'N' ) ) ---> FIREFOX.EXE = NOFIREFOX.EXE equals FALSE



Each archive I've seen contain the folder "firefox", "thunderbird" etc. depending on content so you could probably use unzip32.dll directly in rexx to find out what package you're actually handling and unzip files accordingly. I found unzip32.dll useful once I tried it, but the documentation in Tips & Tricks is a must.
You could probably replace "firefox" in the array NoDel.1 to 3 with names from the path in the .zip-file (list with unzip32.dll). That way you could use one script to install Firefox, Thunderbird and Seamonkey. :)

//Jan-Erik

sXwamp

#6
Thanks Robert and Jep,

This code above from Robert and modified code from Jep only deletes one file and ends.  I added a loop around the code to test it to see what happens. Both deletes all the files, but the last three files left are:

application.ini
blocklist.xml
chrome.manifest

Any tips or ideas what I'm going wrong ???

There must be a logic error somewhere. I did have some progress messing around with it - the code below deletes all the file but the first item in the NoDel list - the other two get deleted.

The only thing I changed from Jeps code is below:


I changed:         rtc = SysFileDelete( filelist.B )    /* delete file */

to           :         rtc = SysFileDelete( filelist.A )    /* delete file */




CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
CALL RxFuncAdd 'SysRmDir', 'RexxUtil', 'SysRmDir'

fDir ='Z:\Unzip\firefox-8.0.1.en-US.os2\firefox'

/* List files and delete each of them */

/* Create Match list of do-not-deletes, upper case! */
   NoDel.1='FIREFOX!K.EXE'
   NoDel.2='FIREFOX.EXE'
   NoDel.3='FIREFOX.ICO'
   NoDel.0=3  /* Set stem array length */

/* Read directory and all sub-directories and create file list in stem array filelist, take care of possible trailing back slash */
/* We only care about the fully qualified path names and in subfolders as well, so use "O" option to drop dates, times, attribs, etc */
   rtc = SysFileTree( STRIP( fDir, 'T', '\' )||"\*", "filelist", "SFO" )  

/* Create worker loops */
   Do A = 1 to filelist.0    /* Loop through file list using count in stem base */
       Do B = 1 to NoDel.0    /* Compare to each value in NoDel array */
           If Pos( NoDel.B, Translate( filelist.A ) ) > 0 Then   /* found a match - using upper case to ensure proper matching */
           Iterate A /* Jump to the next file in the list and don't process this one! */

       rtc = SysFileDelete( filelist.A )    /* delete file */

End

       /* Add programming code here to check error codes if wanted - for instance cant delete because locked file */
       /* If rtc = 0 Then Say FileSpec( filelist.A, 'N' ) 'deleted' */
   End



All most there, need some more help please !


Thanks again,

Greggory

jep

#7
Quote from: sXwamp on 2011.12.06, 14:01:25
Thanks Robert and Jep,

This code above from Robert and modified code from Jep only deletes one file and ends.  I added a loop around the code to test it to see what happens. Both deletes all the files, but the last three files left are:

I can't see any additional loop? But the required addition by you is there
fDir ='Z:\Unzip\firefox-8.0.1.en-US.os2\firefox'

Quote from: sXwamp on 2011.12.06, 14:01:25
application.ini
blocklist.xml
chrome.manifest

Any tips or ideas what I'm going wrong ???
Do any of these files have the read only flag set (settings notebook)?!
If so, then you'll have to use e.g.
'attrib "'||filelist.A||' -r -a -s -h'

Another possible problem may be if there's any application that has opened those files.
Output the return code from SysFileDelete (error checking)
If rtc <> 0 THEN
 SAY 'Could not delete' filelist.A', error code:' rtc

Quote from: sXwamp on 2011.12.06, 14:01:25
There must be a logic error somewhere. I did have some progress messing around with it - the code below deletes all the file but the first item in the NoDel list - the other two get deleted.

The only thing I changed from Jeps code is below:


I changed:         rtc = SysFileDelete( filelist.B )    /* delete file */

to           :         rtc = SysFileDelete( filelist.A )    /* delete file */

My fault! Of course it should be filelist.A and the End instruction has to be moved before the SysFileDelete so that it do the check for all (3) items in list before it delete the file.

See my corrections and additions with attrib etc.

CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
CALL RxFuncAdd 'SysRmDir', 'RexxUtil', 'SysRmDir'

fDir ='Z:\Unzip\firefox-8.0.1.en-US.os2\firefox'

/* List files and delete each of them */

/* Create Match list of do-not-deletes, upper case! */
   NoDel.1='FIREFOX!K.EXE'
   NoDel.2='FIREFOX.EXE'
   NoDel.3='FIREFOX.ICO'
   NoDel.0=3  /* Set stem array length */

/* Read directory and all sub-directories and create file list in stem array filelist, take care of possible trailing back slash */
/* We only care about the fully qualified path names and in subfolders as well, so use "O" option to drop dates, times, attribs, etc */
   rtc = SysFileTree( STRIP( fDir, 'T', '\' )||"\*", "filelist", "SFO" )  

/* Create worker loops */
   Do A = 1 to filelist.0    /* Loop through file list using count in stem base */
       'attrib "'||filelist.A||' -r -a -s -h' /* turn off read only, archive, s...omething */
       Do B = 1 to NoDel.0    /* Compare to each value in NoDel array */
           If Pos( NoDel.B, Translate( filelist.A ) ) > 0 Then   /* found a match - using upper case to ensure proper matching */
           Iterate A /* Jump to the next file in the list and don't process this one! */
       End /* Has to be placed before code that delete the file */
       rtc = SysFileDelete( filelist.A )    /* delete file */
       /* Add programming code here to check error codes if wanted - for instance cant delete because locked file */
       If rtc = 0 Then Say FileSpec( filelist.A, 'N' ) 'deleted'
       Else SAY 'Could not delete' filelist.A', error code:' rtc
   End

<snip>

//Jan-Erik

sXwamp


I got it done ;D

http://www.os2notes.com/os2firefoxdd.html


Thanks Andre, Robert, and Jan-Erik - for all the help !!!


Greggory