Re: Rexx problem? - advice sought, Please
- From: Uwe Pilgram <Uwe.Pilgram@xxxxxxxxxxx>
- Date: Fri, 14 Apr 2006 14:13:05 +0000
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
- References:
- Rexx problem? - advice sought, Please
- From: Peter Brown
- Rexx problem? - advice sought, Please
- Prev by Date: Re: PM split window
- Next by Date: Re: PM split window
- Previous by thread: Re: Rexx problem? - advice sought, Please
- Next by thread: Named segments and link386?
- Index(es):
Relevant Pages
|
Loading