10.10.2020, 03:21
Hi,
I can write to a USB drive, then unplug it and read the contents on another computer. However, Is there a way to reads the USB drive contents remotely?
I was thinking to FTP in via the apps' credentials, and this allows me to see the /user directory. I can see files I have put into that directory via previous FTP sessions.
However, can I FTP my way to the USB contents? Or, as second best, how to write the code to copy a file from the USB dive to the /user directory, which I can then retrieve via FTP.
I have been playing with the following code:
The first lot of code works and creates the 12 line file on the USB stick. The other os.execute commands either work or don't work as shown. Am I heading down the right path?
So, my questions summarised:
1) Can we reach the USB drive directly via FTP?
2) Failing that, can we copy files from the USB drive to the /user directory?
Thanks!
I can write to a USB drive, then unplug it and read the contents on another computer. However, Is there a way to reads the USB drive contents remotely?
I was thinking to FTP in via the apps' credentials, and this allows me to see the /user directory. I can see files I have put into that directory via previous FTP sessions.
However, can I FTP my way to the USB contents? Or, as second best, how to write the code to copy a file from the USB dive to the /user directory, which I can then retrieve via FTP.
I have been playing with the following code:
Code:
1234567891011121314151617181920212223242526272829303132
-- Write a test USB stick file
res, err = mount_usb()
log('After mounting, result is', res, err)
if res then
f, err = io.open('/mnt/testfile', 'a')
if f ~= nil then
f:write(os.date("Starting log at %X on %A, %d %B %Y")..'\n')
for i = 1, 10 do
f:write('Hello!'..'\n')
end
f:write(os.date("Finished log at %X on %A, %d %B %Y")..'\n')
f:close()
log('Wrote to USB drive')
else
alert('Unable to write to file: ' .. err)
end
os.execute('cp /mnt/* /user') -- doesn't work
os.execute('touch /user/Test.tst') -- doesn't work
os.execute('touch /mnt/Test.tst') -- works!
os.sleep(2)
log('finished')
unmount_usb()
else
alert(err)
endThe first lot of code works and creates the 12 line file on the USB stick. The other os.execute commands either work or don't work as shown. Am I heading down the right path?
So, my questions summarised:
1) Can we reach the USB drive directly via FTP?
2) Failing that, can we copy files from the USB drive to the /user directory?
Thanks!