Re: Rexx problem? - advice sought, Please



Hi all,

as stated by others, Peter was hit by a common misinterpretation of the path syntax as defined by good old DOS. IIRC the following should be taken into account (" are for better readability only):

1. all path definitions are relative to the current directory
2. a path is made up of "\" delimited names
3. "\" is the path of root directory
4. "." is a shortcut for the current directory
5. ".." is a shortcut for the parent of the current directory
6. A filename in the directory is not part of the path

Unfortunately many commands like "Copy", "CD", etc don't accept or supply a trailing "\" for a path. This is a 25 year old misconception but FOL.

Examples (Start with Drive S: current is root):

Command Results in current
------- ------------------
CD -> S:\
MD Test -> S:\
CD Test -> S:\Test
CD .. -> S:\
CD \Test\ -> Error SYS0003 (Cannot find a directory with empty name in "Test"
CD \Test\. -> S:\Test
CD \Test\.. -> S:\

In REXX function Directory() gets the same result as CD. Consequently we get "\" for root and "\Namea\Nameb" for non-root. Trying to simply add "\Filename" is therefore not possible and will fail in case of "current" being the root.

Solution
--------
DriveDir = Strip(Directory(),"T","\")"\";
"Copy" DriveDir"Myfilename" ....;

Best regards
Uwe

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

Peter Brown wrote:
Hi All

With all the recent posts about Rexx this looks the right place to ask a few questions :-)

I wrote a little rexx script to install a small application I'm developing. There have been several public betas of this application using the install script.

I recently got an email stating that the script does not work - I have not got any that say it does work but it has been successfully tested on 3 systems here and I feel confidant that more people would email me about this if it was a problem on their system(s).


This is the script:-

/* install.cmd */
/* Author: Peter Brown */
/* Purpose: Install USBcfg.exe, USBcfg.hlp and setup USB program object in System Setup folder */
/* Modified for beta5 to distinguish between eCS and OS/2 */

call rxFuncAdd "SysLoadFuncs" , "RexxUtil" , "SysLoadFuncs"
call SysLoadFuncs

boot_drive = ''
boot_drive = SysBootDrive()

name = "USB"
dir = directory()

/* eCS or OS/2? */
call SysFileTree boot_drive||'\ecs\bin', 'file', 'D'
If file.0=1 Then
Do
/* eCS */
'@Copy ' ||dir||"\USBCFG.EXE" boot_drive||"\ecs\bin\USBCFG.EXE"
'@Copy ' ||dir||"\USBCFG.HLP" boot_drive||"\ecs\help\USBCFG.HLP"

PRGOPTION="EXENAME="||boot_drive||"\ecs\bin\USBCFG.EXE;OBJECTID=<USBCFG_EXE>"

/* just in case the app was previously installed in [BootDrive]:\os2 */
call SysFileTree boot_drive||'\OS2\USBCFG.EXE', 'thefile', 'F'
If thefile.0=1 Then
Do
'@Del' boot_drive||'\OS2\USBCFG.EXE'
'@Del' boot_drive||'\OS2\USBCFG.HLP'
'@Del' boot_drive||'\OS2\USBCFG.INI'
End
/* just in case the help file, usbcfg.hlp, was previously installed in [BootDrive]:\ecs\bin */
call SysFileTree boot_drive||'\ecs\bin\USBCFG.HLP', 'helpfile', 'F'
If helpfile.0=1 Then
Do
'@Del' boot_drive||'\ecs\bin\USBCFG.HLP'
End
End
Else
Do
/* OS/2 */
'@Copy ' ||dir||"\USBCFG.EXE" boot_drive||"\OS2\USBCFG.EXE"
'@Copy ' ||dir||"\USBCFG.HLP" boot_drive||"\OS2\USBCFG.HLP"
PRGOPTION="EXENAME="||boot_drive||"\OS2\USBCFG.EXE;OBJECTID=<USBCFG_EXE>"
End
/* Create program object */
rc=SysCreateObject("WPProgram",name,"<WP_CONFIG>",PRGOPTION,"REPLACE")

Exit



The email about the script failure :-


I unpacked the archive into the root of my ramdisk, as usual in those cases, and ran the script, but got the following error messages:

Q:\>install.cmd
Q:\\USBCFG.EXE
SYS0003: Der angegebene Pfad konnte nicht gefunden werden.
0 Datei(en) kopiert
Q:\\USBCFG.HLP
SYS0003: Der angegebene Pfad konnte nicht gefunden werden.
(' the specified path couldn't be found')
0 Datei(en) kopiert
('0 file(s) copied')


I'm not really deep into ReXX programming at all, but after playing around a bit with the section of the script causing the problem, I got lucky and found out, how to make it work for me.


Do
'@echo OS2 Loop'
/* OS/2 */
'@echo' dir
'@dir' dir||"USBCFG.EXE"
'@dir' boot_drive||"\OS2\USBCFG.EXE"
'@Copy ' ||dir||"USBCFG.EXE" boot_drive||"\OS2\USBCFG.EXE"
'@Copy ' ||dir||"USBCFG.HLP" boot_drive||"\OS2\USBCFG.HLP"


I had to remove the trailing "\" in front of the source file names in both '@Copy' lines, since apparently "dir = directory()" in my case delivers "Q:\", having me ending up with two back slashes, which of course confused the 'Copy' command.




Several questions:

Why does this fail on 1 system - and possibly more, I guess - with this extra backslash: where does the extra backslash come from?

Is this a Rexx problem or just something about the system that it is being used on?

Not being much of a Rexx programmer I would appreciate someone illustrating the best way to catch this error and then use the modified command lines as used successfully by the person reporting the problem.

Regards

Pete
.



Relevant Pages

  • RE: Location of web root
    ... Subject: Location of web root ... during install) pointing out that a Custom install will allow for a more ... in a different folder off C:. ... were the script kiddie, how would you exploit the machine. ...
    (Security-Basics)
  • Rexx problem? - advice sought, Please
    ... I wrote a little rexx script to install a small application I'm developing. ... There have been several public betas of this application using the install script. ...
    (comp.os.os2.programmer.misc)
  • Re: Deploy Root CA to 98
    ... > We have a few 98 machines left, and after implementing our first ever Root ... > transparently on client Windows 98 computer in an Active Directory Networked ... You could also use a capicom script to install the root as a trusted ...
    (microsoft.public.windows.server.security)
  • Re: suid bit files + securing FreeBSD (new program: LockDown)
    ... I really like the sound of having a shell script to run and lock ... down systems right after install; ... >> to root with a list of the files it found which had improper ... >> daemon which checks the conf file and program periodically, ...
    (FreeBSD-Security)
  • Local module installation
    ... Bicking). ... How do I install the modules inside ... my WWW root in order for them to be found when I try to import them? ... have a config.py script on my WWW root that is imported on every other ...
    (comp.lang.python)

Loading