Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5228

Beginners • Re: Copy file from raspberry pi to computer then delete it?

$
0
0
You can use ssh to pass commands to the Pi (not a Windows user so I am unsure if that is present or not). This is best done with secure keys between the devices (see here - unsure how this works on Windows outside of Putty but you may have this set up for the copy).

Code:

ssh pi@192.168.0.51 'rm /home/pi/test/test.log'
BUT this is not a good idea:

How do you check the file is available and ready to copy?

You need to check the file has copied over correctly from the SCP command - does that give an error level you can check?

You may need to stop tasks on the Pi from locking the file (they may still have it open) - depends on how the file is created?

You may need to create a new blank log file for the program to append to - it may error if the file does not exist

You need to check the file is deleted on the Pi - this could lead to a loss of data if the program on the Pi adds to the file between the copy and delete (unlikely but better safe than sorry).

I would look at using something like Syncthing https://syncthing.net or rsync (many tutorials - see here for a Windows 10 one) and trigger this from the Pi (i.e. push) at a time that is correct for the file to be available. Both of these have error recovery.

Statistics: Posted by MiscBits — Wed Feb 21, 2024 12:34 pm



Viewing all articles
Browse latest Browse all 5228

Trending Articles