Rocket U2 | UniVerse & UniData

 View Only

 UNIVERSE COPY/MOVE Binary Files using UNIBASIC

Jump to Best Answer
Aaron Glover's profile image
Aaron Glover posted 07-05-2021 08:33
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's profile image
ROCKETEER Jonathan Smith Best Answer
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

David Green's profile image
David Green
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's profile image
ROCKETEER Jonathan Smith
@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.
Manu Fernandes's profile image
PARTNER Manu Fernandes
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's profile image
Aaron Glover
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.