Joining two binaries files into one

Hi,

I am currently trying to join two binaries files on a managed zebra device to merge them into a third one.

In DOS/windows i can use the command "copy file1.bin + file2.bin destination.bin /B" and in linux the command "cat file1.bin  file2.bin > destination.bin"

So i wanted to know if either by using the legacy script (copy?), javascript(io.file?) or any other tricks i could send a command to the device to mimic such behavior ?

a year ago
SOTI MobiControl
ANSWERS
ZC
Zafer Cigdem Platinum Contributor
a year ago

Hi Benoit,

For Android devices you can use JavaScript for this. Let's say you have 2 binary files as file_one.bin and file_two.bin under sdcard/Zafer/Download path on the Android device side. You can read data by using each bin files and save it as property and after that you can create a new file to combine all the information, you can also use data validation or add anything here on the top of the data coming from files by using JS. You can review below and let me know if you have any questions:


var file_1= new mobicontrol.io.File('/sdcard/Download/Zafer/file_one.bin');
var text_1 = file_1.readText();


var file_2= new mobicontrol.io.File('/sdcard/Download/Zafer/file_two.bin');
var text_2 = file_2.readText();

var full_text = text_1 + " \n" + text_2
 
var file_combined= new mobicontrol.io.File('/sdcard/Download/Zafer/file_combined.bin');
file_combined.writeText(full_text);

B
Benoit
a year ago

Hi Zafer,

Thanks a lot for your answer,

About your solution, it was really an interesting one and i did check the readtext() method in the JS Soti documentation to see if it could solve my problem.

Sadly for me it is really limited in its usage since it only works for UTF-8 Text files who are less than 2MB, totaly out of the scope of my binaries files which are in binary format and over 1GB big.

I assume i must look for a different way to join them than simply using the SOTI JS agent or the legacy script.

ZC
Zafer Cigdem Platinum Contributor
a year ago

Hi Benoit,

it's a pleasure!

I could not imagine that your file would be less such as config or such, you are right:)

what do you want to do with these files at the end, do you need the combined file on the Android device side, or any other side?

You can think of to deliver these files from Android device to server by using device-to-server FileSync Rule/Policy, and combine it on the server side by using a basic automation piece of code, and then get it back to device side or publish to other side, but as it consumes so much traffic and data, I would not prefer this, unless there is no other solution or this requires from many devices and more than 1 time.

I'll follow up this thread and share my feedback if I can think any other alternative.

E
ENMod Bronze Contributor
a year ago

Hey Benoit,

Thanks for posting on SOTI pulse. Thanks Zafer for responding to the post, your expertise and willingness to help are greatly appreciated!


Has your query been resolved? If not, or if you have any additional concerns, please don't hesitate to reach out. We are dedicated to providing assistance and support.


Also, if this post has helped you in solving your query, I would request you to mark the particular comment as "is solution", so that others may benefit from this information.

Technical Support, SOTI | Call Us | SOTI.net | Discussion Forum | Log a Case Online