# EXEC node can not change directory

**URL:** https://discourse.nodered.org/t/exec-node-can-not-change-directory/43522
**Category:** General
**Created:** [1 April 2021 20:02 UTC](https://discourse.nodered.org/t/exec-node-can-not-change-directory/43522 "2021-04-01T20:02:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![sweetwater](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sweetwater](https://discourse.nodered.org/u/sweetwater)
#### Post date: [1 April 2021 20:02 UTC](https://discourse.nodered.org/t/exec-node-can-not-change-directory/43522/1 "2021-04-01T20:02:34Z")

</div>

Running NODE RED on a Raspberry PI and i have had great success with it .  
But there is one strange problem I am stuck on:

I have a tar file called "dist.tar" in the directory called /home/pi/sweetwater/public

When I SSH into the pi and enter the command 'tar xf dist.tar' the tar file decompress correctly.  
Once we establshed this, we then moved on to mimic this with the EXEC node.

I then proceed to create an EXEC node

EXEC node 1 is 'cd /home/pi/sweetwater/public'  
EXEC node 2 'tar xv dist.tar'

However, when check the directory ( using EXEC node with 'ls-a'), it clearly shows the directly is not changing.

Running ls-a command on the EXEC always shows the following.  
.  
..  
bin  
boot  
dev  
etc  
home  
lib  
lost+found  
media  
mnt  
opt  
proc  
root  
run  
sbin  
srv  
sys  
tmp  
usr  
var

Any clues?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [1 April 2021 20:37 UTC](https://discourse.nodered.org/t/exec-node-can-not-change-directory/43522/2 "2021-04-01T20:37:04Z")

</div>

Anything you do in one exec node will not affect what happens in another. You can either specify the full path name to the files in the command, so the current directory does not matter, or you can put, in the exec node  
`cd /home/pi/sweetwater/public && tar xv dist.tar`

---

<div class="post-metadata">

### Author: ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)
#### Post date: [1 April 2021 20:37 UTC](https://discourse.nodered.org/t/exec-node-can-not-change-directory/43522/3 "2021-04-01T20:37:45Z")

</div>

The exec node is not one continuous ssh session in a single shell happening so you won’t be able to use commands like this in different exec nodes in succession.  
The simplest solution would be to use the absolute path in your tar command to accomplish the task in a single exec:

```auto
tar xv /home/pi/sweetwater/public/dist.tar

```

the other way would be to put the commands in a shell script and execute that script with the exec node.

Johannes

---

<div class="post-metadata">

### Author: ![sweetwater](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sweetwater](https://discourse.nodered.org/u/sweetwater)
#### Post date: [2 April 2021 13:04 UTC](https://discourse.nodered.org/t/exec-node-can-not-change-directory/43522/4 "2021-04-02T13:04:53Z")

</div>

Thank you Colin and JGKK. Your hints pointed me to the correct solution  
. I changed to singel command as you suggested.  
I ultimately changed to:  
tar -xvf /home/pi/sweetwater/public/dist.tar -C /home/pi/sweetwater/public

So the problem was my lack of understanding of the linux command format.

---

<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: [1 June 2021 13:05 UTC](https://discourse.nodered.org/t/exec-node-can-not-change-directory/43522/5 "2021-06-01T13:05:48Z")

</div>

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