title: How to pass variables from a shell script to an expect script?
body: <p>I've shell script as below:</p>
  
  <pre><code>#!/bin/bash
  
  echo "Select the Gateway Server:"
  echo "   1. Gateway 1"
  echo "   2. Gateway 2"
  echo "   3. Gateway 3"
  
  read gatewayHost
  
  case $gatewayHost in
      1) gateway="abc.com" ;;
      2) gateway="pqr.com" ;;
      3) gateway="xyz.com" ;;
      *) echo "Invalid choice" ;;
  esac
  
  /mypath/abc
  </code></pre>
  
  <p>In above script, I'm fetching gateway from user input selection &amp; trying to pass to my abc.sh script which is expect scriptshown below:</p>
  
  <pre><code>#!/usr/bin/expect
  
  set timeout 3
  spawn ssh "james@$gateway"
  expect "password:"
  send "TSfdsHhtfs\r";
  interact
  </code></pre>
  
  <p>But I'm not able to pass gateway variable from shell script to expect script. Can any one tell me how to achieve this?? Please note that I need to use shell script only due to legacy reasons (Cannot use tcl script or can't do everything in expect script itself)</p>