Example: In a shell script I open a SSH tunnel whit this:
/usr/bin/expect <<EOD
set timeout -1
spawn ssh -fNL localhost:1873:localhost:873 HOST
expect "*?assword:" { send "$SSHPASS\r"}
sleep 2
exit [exp_pid]
EOD
export SSH_PID=$?
echo $SSH_PID
now $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?
