How to include OS command?

BeanTee

New Member
I'm trying to zip a folder but i hit an error when i run the script.

when i run the below command via command line, i'm able to zip the folder without error.
"C:\Program Files\WinZip\WINZIP32.EXE" -min -a "C:\SST1\ihb889.zip" "C:\SST1\ihb889\*.*"

However, when i include the command in my script and run it... I encounter an error...

def var nvzip as char format "x(100)".
nvzip = "~"" + "C:\Program Files\WinZip\WINZIP32.EXE" + "~"" + " -min -a " +
"~"" + "C:\SST1\ihb889" + ".zip" + "~" " +
"~"" + "C:\SST1\ihb889" + "\*.*" + "~"".
os-command value (nvzip).


Error...
'C:\Program' is not recognized as an internal or external command, operation program or batch file.

Did i miss something here? Tried to troubleshoot but with no luck. Can anyone help?
 
Last edited:
Try the below code:

Code:
DEFINE VARIABLE czipexe     AS CHARACTER  NO-UNDO.
DEFINE VARIABLE cflags      AS CHARACTER  NO-UNDO.
DEFINE VARIABLE czipTo      AS CHARACTER  NO-UNDO.
DEFINE VARIABLE czipFrom    AS CHARACTER  NO-UNDO.

ASSIGN
    czipexe  = 'C:\Program Files\WinZip\WINZIP32.EXE '
    cflags    = " -min -a "
    czipTo    = " C:\temp\RZR.zip "
    czipFrom  = " C:\Temp\*.* ".

OS-COMMAND SILENT VALUE('"' + czipexe + '"' + cflags + czipTo + cZipFrom).
 
it works!!!
Do you mind to explain what makes the different? Double quote ' " ' cannot be recognized in os-command?
 
Last edited:
Might not be the best solution, but it is one that works for me. Plus, it solves the problem that the OS-COMMAND does not have any error handling at all:

I always create a OS shell script ( or Windows .bat ) on-the-fly which always writes any errors to another file that I can parse afterwards to see whether something went wrong ...

Heavy Regards, RealHeavyDude.
 
It has 'some' error handling - you can redirect stdout and stderr to files and grab the contents of them:

Code:
DEF VAR cstdout   AS CHAR INIT "c:\temp\hello.stdout".
DEF VAR cstderr   AS CHAR INIT "c:\temp\hello.stderr".
DEF VAR lcstdout  AS LONGCHAR.
DEF VAR lcstderr  AS LONGCHAR.

OS-COMMAND SILENT VALUE( SUBSTITUTE( 'hello.cmd 1> "&1" 2> "&2"', cstdout, cstderr ) ).

COPY-LOB FROM FILE cstdout TO lcstdout.
COPY-LOB FROM FILE cstderr TO lcstderr.
MESSAGE 
   "stdout" SKIP 
   STRING( lcstdout ) SKIP (1)
   "stderr" SKIP
   STRING( lcstderr )
VIEW-AS ALERT-BOX.

Beware that when wrapping stuff like this around progress commands like prolib, progress dumps everything into stdout.
 
Back
Top