Skip to main content
Aaron Glover
Inspiring
Jul 5, 2021 8:29 AM UTC
Solved

UNIVERSE COPY/MOVE Binary Files using UNIBASIC

Hi All

Assuming I have appropriate permissions on the file system can anyone tell me if it is possible to copy/move from a UNIBASIC program?

I have explored READBLK and WRITEBLK but the file always seems to be corrupt after writing.

Example scenario; move/copy a word doc or PDF file from one directory to another.

Alternatively is there a way to shell execute a command to the local server or execute a powershell command etc.

Thanks In Advance
Aaron

    Jonathan Smith
    Rocketeer
    Jul 5, 2021 8:36 AM UTC
    Hi All

    Assuming I have appropriate permissions on the file system can anyone tell me if it is possible to copy/move from a UNIBASIC program?

    I have explored READBLK and WRITEBLK but the file always seems to be corrupt after writing.

    Example scenario; move/copy a word doc or PDF file from one directory to another.

    Alternatively is there a way to shell execute a command to the local server or execute a powershell command etc.

    Thanks In Advance
    Aaron

    Aaron,

    Why not use the EXECUTE command to execute a shell level command.
    For Windows EXECUTE " DOS /c 'copy xxx xxx' "
    For UNIX EXECUTE " sh -c 'cp xxxxx xxxx' "

    Thanks,
    Jonathan

    Rocket Software - Senior Principal Technical Support Engineer - UniData ATS

    5 replies

    Jonathan Smith
    Rocketeer
    Jul 5, 2021 8:36 AM UTC
    Hi All

    Assuming I have appropriate permissions on the file system can anyone tell me if it is possible to copy/move from a UNIBASIC program?

    I have explored READBLK and WRITEBLK but the file always seems to be corrupt after writing.

    Example scenario; move/copy a word doc or PDF file from one directory to another.

    Alternatively is there a way to shell execute a command to the local server or execute a powershell command etc.

    Thanks In Advance
    Aaron

    Aaron,

    Why not use the EXECUTE command to execute a shell level command.
    For Windows EXECUTE " DOS /c 'copy xxx xxx' "
    For UNIX EXECUTE " sh -c 'cp xxxxx xxxx' "

    Thanks,
    Jonathan

    Rocket Software - Senior Principal Technical Support Engineer - UniData ATS
    David Green
    Inspiring
    Jul 5, 2021 8:41 AM UTC
    Hi All

    Assuming I have appropriate permissions on the file system can anyone tell me if it is possible to copy/move from a UNIBASIC program?

    I have explored READBLK and WRITEBLK but the file always seems to be corrupt after writing.

    Example scenario; move/copy a word doc or PDF file from one directory to another.

    Alternatively is there a way to shell execute a command to the local server or execute a powershell command etc.

    Thanks In Advance
    Aaron

    Aaron, looks like you are using UniVerse.  I don't remember my UniVerse days very well.  But in UniData before doing any binary reads/writes I would always use NOCONVERT to stop the conversion of null.   To execute an OS command from UniBasic I would always use PCPERFORM or start my command with a ! character.
    Jonathan Smith
    Rocketeer
    Jul 5, 2021 8:46 AM UTC
    Hi All

    Assuming I have appropriate permissions on the file system can anyone tell me if it is possible to copy/move from a UNIBASIC program?

    I have explored READBLK and WRITEBLK but the file always seems to be corrupt after writing.

    Example scenario; move/copy a word doc or PDF file from one directory to another.

    Alternatively is there a way to shell execute a command to the local server or execute a powershell command etc.

    Thanks In Advance
    Aaron

    @David Green

    NOCONVERT is not available in UniVerse.
    PCPERFORM is also not available in UniVerse.
    For UniVerse to run a shell command is 'DOS /c' on Windows  and 'sh -c' for Unix but the command has to enclosed in single quotes.
    Rocket Software - Senior Principal Technical Support Engineer - UniData ATS
    Manu Fernandes
    Inspiring
    Jul 5, 2021 8:52 AM UTC
    Hi All

    Assuming I have appropriate permissions on the file system can anyone tell me if it is possible to copy/move from a UNIBASIC program?

    I have explored READBLK and WRITEBLK but the file always seems to be corrupt after writing.

    Example scenario; move/copy a word doc or PDF file from one directory to another.

    Alternatively is there a way to shell execute a command to the local server or execute a powershell command etc.

    Thanks In Advance
    Aaron

    Hello
    Best practice is a os statement.
    On windows use 'DOS /C stmt' it start a cmd.exe and execute stmt. 
    on Unix use 'SH-c statement' it start a SH and execute stmt. 

    I hope this help
    Aaron Glover
    Inspiring
    Jul 5, 2021 9:19 AM UTC
    Hi All

    Assuming I have appropriate permissions on the file system can anyone tell me if it is possible to copy/move from a UNIBASIC program?

    I have explored READBLK and WRITEBLK but the file always seems to be corrupt after writing.

    Example scenario; move/copy a word doc or PDF file from one directory to another.

    Alternatively is there a way to shell execute a command to the local server or execute a powershell command etc.

    Thanks In Advance
    Aaron

    Thanks all.

    I was never aware i could use EXECUTE() to run a dos command. A cursory glance at the Unibasic Command Reference doesnt give any hint that I can do as suggested and execute a DOS command.

    And to clarify; yes I am using Universe on Windows.

    Thanks Again.