title: expect command is not passing env variable in ubuntu focal
body: <p>I'm using <code>expect</code> (v5.45.4-2build1) to automate generation of client certs using easy-rsa in ubuntu focal.
  As per easy-rsa, to customize cert validity we need to pass <code>EASYRSA_CERT_EXPIRE</code> variable.
  But for some reason, my expect script is not able to fetch this variable.
  Here's the code for script.exp:</p>
  <pre><code>#!/usr/bin/expect -f
  
  set timeout -1
  #exp_internal 1
  
  set MY_PASSPHRASE [lindex $argv 0];
  set USERNAME [lindex $argv 1];
  set ttl [lindex $argv 2];
  
  send &quot;export EASYRSA_CERT_EXPIRE=$ttl\r&quot;
  spawn /bin/bash
  
  set MSG &quot;Executing script.exp for $USERNAME and $ttl&quot;;
  send &quot;echo 'INFO $MSG'&gt;&gt; /var/log/app/my_app.log\r&quot;
  
  send &quot;cd /etc/openvpn/easy-rsa\r&quot;
  
  send &quot;export EASYRSA_CERT_EXPIRE=$ttl\r&quot;
  
  send &quot;./easyrsa gen-req $USERNAME\r&quot;
  expect &quot;*Enter PEM pass phrase:&quot;
  send -- &quot;$MY_PASSPHRASE\r&quot;
  expect &quot;*Verifying - Enter PEM pass phrase:&quot;
  send -- &quot;$MY_PASSPHRASE\r&quot;
  expect &quot;*Common Name *$USERNAME*&quot;
  send -- &quot;\r&quot;
  expect &quot;*Keypair and certificate request completed*&quot;
  send -- &quot;\r&quot;
  exit 0
  </code></pre>
  <p>Strangely, this works fine if i run the script via <code>expect script.exp</code>.
  But I want to use this in my perl script and it is not working from the perl script.</p>
  <p>This is how I'm calling my expect script:</p>
  <pre><code>my $cmd_out_csr = system(&quot;expect script.exp $my_passphrase $username $ttl&quot;);
  </code></pre>
  <p>Just running, <code>expect script.exp $my_passphrase $username $ttl</code> from cmd works fine.
  Any help is appreciated.
  Thanks.</p>