EXEC node can not change directory

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?

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

1 Like

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:

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

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.

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