Skip to main content
Solved

UNIVERSE COPY/MOVE Binary Files using UNIBASIC

  • July 5, 2021
  • 5 replies
  • 1 view

Aaron Glover
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

Best answer by Jonathan Smith

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

5 replies

Jonathan Smith
Forum|alt.badge.img
  • Rocketeer
  • 356 replies
  • Answer
  • July 5, 2021
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


David Green
  • Inspiring
  • 48 replies
  • July 5, 2021
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
Forum|alt.badge.img
  • Rocketeer
  • 356 replies
  • July 5, 2021
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.

Manu Fernandes
Forum|alt.badge.img+2
  • Inspiring
  • 257 replies
  • July 5, 2021
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
  • Author
  • Inspiring
  • 14 replies
  • July 5, 2021
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.