Multiple Command via Input Thru?

dayv2005

Member
I'm working on a simple script that will run when the app is started. It will search the users temp dir and then create a temp-table of file information. Then loop through the temp table and delete files that are older than 30 days.

THe problem I'm having is that i can't run multiple commands with the input through. I even tried using an escape char for carriage return. No luck, i think i'm doing it wrong and was wondering if someone could help me out here.

This is my code.

Code:
DEFINE VARIABLE cmdLine  AS CHARACTER   NO-UNDO.
DEFINE VARIABLE cTempDir AS CHARACTER   NO-UNDO.
DEFINE VARIABLE cUser    AS CHARACTER   NO-UNDO.
DEFINE VARIABLE feedBack AS CHARACTER   NO-UNDO.
DEFINE VARIABLE OutStrg AS CHARACTER   NO-UNDO.
DEFINE VARIABLE batchFile AS CHARACTER   NO-UNDO.
DEFINE VARIABLE daysBack AS INTEGER     NO-UNDO.

DEFINE TEMP-TABLE ttFileInfo
    FIELD FILE-CREATE-DATE AS DATE       
    FIELD FILE-CREATE-TIME AS INTEGER    
    FIELD FILE-MOD-DATE    AS DATE       
    FIELD FILE-MOD-TIME    AS INTEGER    
    FIELD FILE-NAME        AS CHARACTER  
    FIELD FILE-SIZE        AS INTEGER    
    FIELD FILE-TYPE        AS CHARACTER  
    FIELD FULL-PATHNAME    AS CHARACTER  
    FIELD PATHNAME         AS CHARACTER  
    FIELD TYPE             AS CHARACTER.

ASSIGN
    cTempDir = SESSION:TEMP-DIRECTORY
    cUser    = USErid(LDBNAME(1))
    cmdLine  = "cd " + cTempDir + " \r " + "dir /b"
    daysBack = 2.
    
INPUT THRU CALL VALUE(cmdLine) NO-CONSOLE NO-WAIT.
REPEAT:
    IMPORT UNFORMATTED feedBack.
    IF feedBack = "" THEN NEXT.

    FILE-INFO:FILE-NAME = feedBack.

    CREATE ttFileInfo.
    ASSIGN
        ttFileInfo.FILE-CREATE-DATE = FILE-INFO:FILE-CREATE-DATE
        ttFileInfo.FILE-CREATE-TIME = FILE-INFO:FILE-CREATE-TIME
        ttFileInfo.FILE-MOD-DATE    = FILE-INFO:FILE-MOD-DATE
        ttFileInfo.FILE-MOD-TIME    = FILE-INFO:FILE-MOD-TIME
        ttFileInfo.FILE-NAME        = FILE-INFO:FILE-NAME
        ttFileInfo.FILE-SIZE        = FILE-INFO:FILE-SIZE
        ttFileInfo.FILE-TYPE        = FILE-INFO:FILE-TYPE
        ttFileInfo.FULL-PATHNAME    = FILE-INFO:FULL-PATHNAME
        ttFileInfo.PATHNAME         = FILE-INFO:PATHNAME
        ttFileInfo.TYPE             = FILE-INFO:TYPE.
END.


FOR EACH ttFileInfo NO-LOCK:
    DISPLAY ttFileInfo.FILE-NAME FORMAT "X(20)".
END.
 

TomBascom

Curmudgeon
Is this UNIX or Windows?

For UNIX you can place multiple commands on a line by separating them with ";" or by organizing a pipeline with "|".

I'm not a Windows guy but I don't think that there is an equivalent to ";". You do have "|" available. You could also, of course, just write a .BAT file and call that.
 

dayv2005

Member
I'm running it from windows, my bad. Yeah i originally did it in a batch files. But i was running into some issues with that. That's probably going to be the way go about it. I was just seeing if i would have been able to do it without the batch file.

This issue hit me before in the past and i was never able to get around it.

Thanks.
 

dayv2005

Member
when i run command prompt in windows "|" works but some reason when i run that .p i posted. i get File Not Found. If i use "|" so now i think this is a new issue.

Wait nvm that actually work i removed the no-console no-wait from it and it works great. Thanks.

Well i thought it was for some reason it didnt change the directory.
 
Top