I have a watch directory node feeding into an exec node that watches for a file to be placed on a FTP server on the Pi. When the file arrives the command moves the file to another location on the FTP server for use. The command works but every time it generates a error 1 " mv: cannot stat and then the whole command and then I get "no such file or directory".
I plug the command into a command prompt and it works fine with no error messages. The exec node works as well - the file is moved and renamed but I get the error message. The file is a .jpg from a camera but I don't think it's a specific file or extension issue, but then I haven't figured out what is wrong either. Worst case I can live with the error message but I'd rather not. I thought it might be a permission thing so I stuck sudo in the command with no changes. It's not easy to get to the pi so posting images of the errors is hard, it's not on a network accessible to the internet and moving all the equipment to another location is extremely problematic. I haul out a monitor and keyboard to work on it. From my limited explanation does anything jump out or do I need to suck it up and live with it?
Let me see if I understand what ou are doing
1 - something places a jpg in a folder on the Pi.
2) the watch
node is monitoring that folder.
3) when a file shows up, you trigger an exec
node to move the file to a different folder on the Pi.
4) you get an error message but the move actually works.
- are you running NR under the user
pi
? (if you ssh ito the machine and runhtop
you should see the user running Node-RED. Typeq
to exit stop) - does the user running NR have premission to add files to the folder you are moving the file to?
You say it is not easy to access the pi but it seems like you are changing NR, so why can't you just SSH into it?
The Pi sits in a utility building about 2 hundred yards from the house. There's no connection from the house to the building. It has electricity and it's own wifi. To move all the sensors back to the house would be huge. The pi ties to a camera that takes a picture on motion as I'm trying to see what's snooping around the building. Yes, I can take my laptop to the building and put my laptop on that wifi and program the Pi. As I'm writing this I see a flaw in my logic. I could take screen shots then come back to the house and upload to the internet. Sigh....
But yes, I'm running the user under Pi. and yes, the files are put into the folder under the user Pi as the camera FTP's to the Pi using that user name.
Just a guess here but I suspect you are not using full path names for the commands and targets. The issue could be that the context your exec node is running in does not have PATH set like it is when you login interactively.
here is the command
mv /home/pi/ftp/chip/chip1/C1_00626EA7D0B2/snap/*.jpg /home/pi/ftp/chip/chip1/chip.jpg
the path works when I either ssh into it or go into the desktop.
For further info,
I'm trying to get just one file into each of several directories. The camera will FTP but it won't over write a previous file so it just increments the file name. When I copy or move the file I overwrite the file in the directory.
Got it. What I'm suggesting, just to eliminate what I first mentioned as the issue, is this:
which mv
and that gives
/usr/bin/mv
on my system so I'd use that, like
/usr/bin/mv /home/pi/ftp/chip/chip1/C1_00626EA7D0B2/snap/*.jpg /home/pi/ftp/chip/chip1/chip.jpg
And if you want mv
to overwrite add the -f
option.
Those are both interactive logins and will get whatever is in the various bash config files.
Put a debug node on the watch node. Possibly you are getting multiple events for each file as the watch triggers as soon as it sees any change, it can trigger before the file is complete. If that is it then use a Trigger node to send nothing then the most recent message after a few seconds. Then you should get only one event for each file.
[Edit] Also select Extend Delay in the Trigger node.
Indeed, as Colin suggests, are you getting multiple watch events ? Maybe you are getting one once it has moved (ie a file removed event) that then retriggers the move request which has already happened.
I always find myself following a watch node with a trigger, it might be a worthwhile enhancement to the node to be able to specify a timeout so that it effectively includes the trigger node feature.
@shel, I forgot to say that the trigger node should also be configured to Extend Delay if new message arrives. I have edited my original post to include that.
It was indeed seeing the file move and then retriggering as @dceejay and @Colin suggested. I wouldn't have thought the watch node could respond that fast it that it would see my actions. I did add the -f as @LosinIt suggested too as I thought that made sense.
Thanks
The watch node uses a low level system event that triggers whenever anything being watched changes. If you write a significant sized file then it can even fire multiple times as the file chunks are written. It does not wait for the end of the file operation to complete. In fact it probably can't tell whether the operation is complete or not.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.