Example: In a shell script I open a SSH tunnel whit this:/usr/bin/expect <<EODset timeout -1spawn ssh -fNL localhost:1873:localhost:873 HOSTexpect *?assword: { send $SSHPASS\r}sleep 2exit [exp_pid]EODexport SSH_PID=$?echo $SSH_PIDnow $SSH_PID has some number, but it is not the PID of the spawned ssh. I tried different ways I found but non worked. Any Idea?
How to get the PID from a spawned process in expect?
shell script;expect