I am trying to use write a script that uses SSH to create a new directory and write to a text file in it. I've got 1 master on a network, and then 3 nodes that I want to create the directory on. These 4 machines are hosted on VMware.
#node1
ssh node1@192.168.1.102 'sudo touch /temp_dirname/host.txt'
ssh node1@192.168.1.102 'echo "node1" | sudo tee /temp_dirname/host.txt'
#node2
ssh node1@192.168.1.103 'sudo touch /temp_dirname/host.txt'
ssh node1@192.168.1.103 'echo "node1" | sudo tee /temp_dirname/host.txt'
#node3
ssh node3@192.168.1.104 'sudo touch /temp_dirname/host.txt'
ssh node3@192.168.1.104 'echo "node1" | sudo tee /temp_dirname/host.txt'
When I run this I get different errors for each node... for nodes 1 and 2 I get
touch: cannot touch '/temp_dirname/host.txt': no such file or directory
and
tee: temp_dirname/host.txt: no such file or directory
and node 3 I get:
touch: setting times of '/temp_dirname/ no such file or directory
and
tee: temp_dirname/host.txt: no such file or directory
I am absolutely confused with this as I thought touch
created files - so why is it no such file or directory.