BASH help with messages

(If I've been here before, sorry. I can't remember.)

I've got a problem where I may need to move files and fs-ops doesn't quite cut the mustard for doing it as it involves wild cards.

So my dillema is this:

This is the message:

{"_msgid":"372c735a.86534c","topic":"","directory":"2020-24","path":"/home/me/TEMP/foo/","payload":"/home/me/TEMP/foo/reboot"}

(Example paths, etc)

I need to send msg.directory and msg.payload to a bash script.
Of course as much as msg.payload may be unvarying: it needs to be from the msg as it is going to be put on different machines and these paths may vary.
msg.directory is variable. It is the year and week number.

Thanks in advance.

I've tried with the template node but it is spitting out ascii codes which I don't think will help.

Example:
(From the above message structure)
mv {{SourcePath}}/Rebooted* {{Destination}}
Trying to make the msg.payload a command.

I get:

mv /home/me/TEMP/foo/reboot/Rebooted* /home/me/TEMP/foo/reboot/2020-24

Which I don't think will work if I send it to the exe node.

I don't think there is much you cannot do with fs-ops.

The directory node let's you use a wild card to get a list of files. Then you can send that array of files to a move node (passing through a function or change node if necessary to tweak anything you like before the messages each the move node)

Well, I may need some help.

Because I tried and it doesn't work.

A reply from github when I asked about what I was doing:

Old issue, but as far as I can understand from the code, wild cards are not supported in the Move node

So it kind of stops me doing what I want.

This is what I have/had:

[{"id":"5e6fb122.e2971","type":"change","z":"9b7e7466.a4b698","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"directory","tot":"msg"},{"t":"set","p":"path","pt":"msg","to":"log_paths","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":4280,"wires":[["5057e468.77a39c","7cf09090.6ab6a"]]},{"id":"5057e468.77a39c","type":"template","z":"9b7e7466.a4b698","name":"add to paths","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{{path}}}reboot","output":"str","x":610,"y":4280,"wires":[["f7522d25.e854","a9329fb3.3ef568"]]},{"id":"7cf09090.6ab6a","type":"debug","z":"9b7e7466.a4b698","name":"RAW","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":450,"y":4240,"wires":[]},{"id":"faaaeaaa.74bb4","type":"moment","z":"9b7e7466.a4b698","name":"","topic":"","input":"","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-ww","locale":"en_AU","output":"","outputType":"msg","outTz":"Australia/Sydney","x":210,"y":4280,"wires":[["5e6fb122.e2971"]]},{"id":"f7522d25.e854","type":"function","z":"9b7e7466.a4b698","name":"Build stuff","func":"//msg.SourcePath = msg.path + \"reboot\";\nmsg.SourcePath = msg.payload;\nmsg.Destination = msg.payload + \"/\" + msg.directory;\nreturn msg;","outputs":1,"noerr":0,"x":180,"y":4320,"wires":[["445b099e.218268"]]},{"id":"a9329fb3.3ef568","type":"debug","z":"9b7e7466.a4b698","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":770,"y":4280,"wires":[]},{"id":"29def37a.d3db04","type":"inject","z":"9b7e7466.a4b698","name":"Weekly","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"50 23 * * 0","once":false,"onceDelay":0.1,"x":170,"y":4240,"wires":[["faaaeaaa.74bb4"]]},{"id":"445b099e.218268","type":"fs-ops-dir","z":"9b7e7466.a4b698","name":"","path":"SourcePath","pathType":"msg","filter":"Rebooted at*","filterType":"str","dir":"payload","dirType":"msg","x":400,"y":4320,"wires":[["a11895ed.469918"]]},{"id":"a11895ed.469918","type":"switch","z":"9b7e7466.a4b698","name":"","property":"payload[0]","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":4320,"wires":[["7680a022.40ee48","c4bbba2d.83793","a9d5ed52.438db8"]]},{"id":"c4bbba2d.83793","type":"fs-ops-mkdir","z":"9b7e7466.a4b698","name":"","path":"SourcePath","pathType":"msg","dirname":"directory","dirnameType":"msg","mode":"777","fullpath":"directory","fullpathType":"msg","x":200,"y":4360,"wires":[["7c410aa0.950d84"]]},{"id":"a9d5ed52.438db8","type":"delay","z":"9b7e7466.a4b698","name":"Delay","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":170,"y":4400,"wires":[["c99cae1e.a65dd8"]]},{"id":"7c410aa0.950d84","type":"debug","z":"9b7e7466.a4b698","name":"1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":390,"y":4360,"wires":[]},{"id":"c99cae1e.a65dd8","type":"split","z":"9b7e7466.a4b698","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":390,"y":4400,"wires":[["9864152e.47845","1b431cb4.6881db"]]},{"id":"9864152e.47845","type":"debug","z":"9b7e7466.a4b698","name":"1d","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":590,"y":4440,"wires":[]},{"id":"1b431cb4.6881db","type":"fs-ops-move","z":"9b7e7466.a4b698","name":"","sourcePath":"SourcePath","sourcePathType":"msg","sourceFilename":"payload","sourceFilenameType":"msg","destPath":"Destination","destPathType":"msg","destFilename":"payload","destFilenameType":"msg","link":false,"x":600,"y":4400,"wires":[["5feaab5c.72b54c"]]},{"id":"5feaab5c.72b54c","type":"debug","z":"9b7e7466.a4b698","name":"2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":770,"y":4400,"wires":[]}]

Given the global and flow things are set - of course.

(Typically)

I tried it again and it works.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.