ERR_INVALID_ARG_VALUE using Exec node

Hi all.

I'm trying to send a command to the "Exec" node, but I always get this error: TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''.

I'm using a function node to set msg.command with my command and then pass the message to the "Exec" node.

Here my flow
[{"id":"31a7b70f.cfcbb8","type":"inject","z":"88792789.5de198","name":"","topic":"","payload":"!","payloadType":"str","repeat":"","crontab":"00 22 * * *","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["33ed1748.4becb8"]]},{"id":"e8ec88db.e13518","type":"exec","z":"88792789.5de198","command":"","addpay":false,"append":"","useSpawn":"false","timer":"120","oldrc":false,"name":"","x":350,"y":100,"wires":[[],[],["b585bfa8.79a9b8"]]},{"id":"33ed1748.4becb8","type":"function","z":"88792789.5de198","name":"","func":"var today = new Date();\ntoday.setTime(today.getTime());\nvar date = today.getFullYear() + \"\" + (today.getMonth() + 1) + \"\" + ('00' + today.getDate()).slice(-2);\n\nvar filename = 'log/' + date + '/log.txt';\n\nmsg.command = \"mkdir log/\" + date + \" && touch \" + filename;\nmsg.filename = filename;\n\nreturn msg","outputs":1,"noerr":0,"x":230,"y":100,"wires":[["e8ec88db.e13518"]]},{"id":"b585bfa8.79a9b8","type":"switch","z":"88792789.5de198","name":"","property":"payload.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":100,"wires":[[],[]]}]

If I write the command in the "Command" property it works perfectly.

What's the problem?

Hi, I see you set msg.command in your function expecting that to be used in the exec node. There is no where in the built in documentation that says use msg.command. Try setting msg.payload instead (in your function) and check the "append msg.payload" option.

1 Like

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