# Filename in Exec node

**URL:** <https://discourse.nodered.org/t/filename-in-exec-node/58310>\
**Category:** General\
**Tags:** node-red-dashboard\
**Created:** [14 February 2022 12:35 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310 "2022-02-14T12:35:36Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lance99](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/32.png) [@Lance99](https://discourse.nodered.org/u/Lance99)\
**Post date:** [14 February 2022 12:35 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/1 "2022-02-14T12:35:36Z")

</div>

When a take a picture a function returns time/date. . The function return this output _msg.filename : string[42]_ _"/home/pi/Pictures/cam3\_20220214-130253.jpg"_. In the Exec node, I currently have this settings -w 800 -h 600 -o ~/Pictures/test\_image.jpg ....  
I want to use this string withe the date/time as filename in Execl. I trided {{msg.filename}}, but with no success. Any suggestions?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [14 February 2022 12:38 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/2 "2022-02-14T12:38:37Z")

</div>

What is the Raspistill node? I can't find it in the flows library.

---

<div class="post-metadata">

**Author:** ![Lance99](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/32.png) [@Lance99](https://discourse.nodered.org/u/Lance99)\
**Post date:** [14 February 2022 12:52 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/3 "2022-02-14T12:52:55Z")

</div>

Sorry for confusing ... it's the Exec node ... someone call it Raspistill, that's how it was mentioned as that ...

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [14 February 2022 12:59 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/4 "2022-02-14T12:59:33Z")

</div>

Can you show us a picture of the way your exec node is set up?

---

<div class="post-metadata">

**Author:** ![Lance99](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/32.png) [@Lance99](https://discourse.nodered.org/u/Lance99)\
**Post date:** [14 February 2022 13:05 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/6 "2022-02-14T13:05:56Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/ef364860e547323a1a1688ae09f495209a4db48d.png)

---

<div class="post-metadata">

**Author:** ![Lance99](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/32.png) [@Lance99](https://discourse.nodered.org/u/Lance99)\
**Post date:** [14 February 2022 13:09 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/7 "2022-02-14T13:09:18Z")

</div>

```auto
[{"id":"d4759f688d0bc9d7","type":"exec","z":"7e6eee155e9a533d","command":"raspistill","addpay":"","append":"-w 800 -h 600 -o ~/Pictures/test_image.jpg -a 4 -a 8","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":560,"y":220,"wires":[["7cd8371234d5ce41"],[],[]]},{"id":"2cb5db1dde091059","type":"template","z":"7e6eee155e9a533d","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<img width=\"800px\" height=\"600px\" src=\"data:image/jpg;base64,{{{payload}}}\">","output":"str","x":920,"y":220,"wires":[["63a819442e06474a"]]},{"id":"7cd8371234d5ce41","type":"base64","z":"7e6eee155e9a533d","name":"","action":"str","property":"payload","x":760,"y":220,"wires":[["2cb5db1dde091059"]]},{"id":"63a819442e06474a","type":"ui_template","z":"7e6eee155e9a533d","group":"c7a43587.2944e8","name":"","order":2,"width":"18","height":"15","format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":1080,"y":220,"wires":[["569d5ce9cd3f4d9c"]]},{"id":"cd0a94492fd443be","type":"inject","z":"7e6eee155e9a533d","name":"","props":[{"p":"payload"},{"p":"topic","v":"","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"num","x":190,"y":220,"wires":[["3a8571dfbade0c5b"]]},{"id":"3a8571dfbade0c5b","type":"function","z":"7e6eee155e9a533d","name":"","func":"var now = new Date();\n// Create formatted time\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\n\n\n// file path with / at the end\nvar path = \"/home/pi/Pictures/\"; // This is the path\nvar filename = \"cam3_\"+yyyy+mm+dd+\"-\"+hh+mm+ss+\".jpg\"; // file name\nmsg.filename = path + filename;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":220,"wires":[["d4759f688d0bc9d7"]]},{"id":"c7a43587.2944e8","type":"ui_group","name":"Default","tab":"fbd536a.22bf9c8","order":1,"disp":true,"width":"18","collapse":false,"className":""},{"id":"fbd536a.22bf9c8","type":"ui_tab","name":"Home","icon":"dashboard"}]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [14 February 2022 13:15 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/8 "2022-02-14T13:15:57Z")

</div>

You could try setting msg.filename to `-o /home/pi/Pictures/cam3_20220214-130253.jpg` ie including the -o  
And in the exec node tick Append. Change "payload" to "filename"

 ![Untitled 5](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7a87d87800c7e0f4d17e45436f0ec6250666eb7e.jpeg)

---

<div class="post-metadata">

**Author:** ![Lance99](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/32.png) [@Lance99](https://discourse.nodered.org/u/Lance99)\
**Post date:** [14 February 2022 13:37 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/9 "2022-02-14T13:37:54Z")

</div>

Error 126 .... i changed the function so now msg.filname is "-o ~/Pictures/cam3\_20220214-140205.jpg". But still Error 126

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 February 2022 13:45 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/10 "2022-02-14T13:45:06Z")

</div>

Where is the error 126 coming from?Node-Red? Excel?  
Is there more information than just 126?

Have you tried attaching a debug node (set to display the complete msg object) to each of the outputs of the `exec` node?

---

<div class="post-metadata">

**Author:** ![Lance99](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/32.png) [@Lance99](https://discourse.nodered.org/u/Lance99)\
**Post date:** [14 February 2022 13:50 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/11 "2022-02-14T13:50:36Z")

</div>

Node-Red ... Error 127.

2/14/2022, 2:47:51 PM[node: 44a171a32813c8ac](http://192.168.10.148:1880/#)msg.payload : Object  
object code: 127

message: "Command failed: /home/pi/Pictures/raspistill -o ~/Pictures/cam3\_20220214-140252.jpg -w 800 -h 600 -a 4 -a 8↵/bin/bash: line 1: /home/pi/Pictures/raspistill: No such file or directory↵"

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 February 2022 13:54 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/12 "2022-02-14T13:54:03Z")

</div>

What happens if you use the full path I.e. /home/pi/Pictures…

---

<div class="post-metadata">

**Author:** ![Lance99](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/32.png) [@Lance99](https://discourse.nodered.org/u/Lance99)\
**Post date:** [14 February 2022 13:57 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/13 "2022-02-14T13:57:49Z")

</div>

ohhhh ,,, full path ... Great!! Thanks you guys.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 February 2022 13:57 UTC](https://discourse.nodered.org/t/filename-in-exec-node/58310/14 "2022-02-28T13:57:51Z")

</div>

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