Let's say there is a case statement within the SSH session. I want to pass the variable entry out of remote machine and store it in local machine's csv file.
The example:
#!/bin/sh
set -x
read -p 'Enter the raspberry ip address you want to connect:' Rasp_id
entry=$(sshpass -pthe@Donut ssh -oStrictHostKeyChecking=no pi@"$Rasp_id" "$(cat << 'E3
cd
read -p 'Enter the case you want to configure\n 1.1 WM \n 2.1 LWM\n' option
case $option in
(1)
read -p 'config_wide_motion token' token_w_m
cat SoundEye/NoCAN/config_nocan.json
cat SoundEye/NoCAN/config_processor_motion.json
entry="1_WM"
;;
(2)
read -p 'config_laser_wide_motion token:' token_l_w_m
cat SoundEye/NoCAN/config_nocan.json
cat SoundEye/NoCAN/config_processor_motion.json
entry="1_LWM"
;;
esac
E3
)"
)
printf "$entry"
However, it doesn't do what I want. I would like to see the entry be either 1_WM or 1_LWM when it finished the last line
ssh user@host cat "$somename" "$someothername"
. Also, you seem to want to cat the same files regardless of user input on the second question, and the variable read is not used. – Kusalananda Jan 06 '21 at 09:47