title: logging a telnet session as a background process
body: <p>I want to achieve the following: We have a telecommunications system which protocols all incoming and outgoing calls and makes the data acessible live via telnet. What I want to do is to run a background script on a Debian VM that is permanently connected with the system and logs the data.
  After a bit of research (I am very unfamiliar with shell scripting) I decided to make use of the tools script and expect.
  The logging part works so far; the background part not so well. I show you the two scripts I have so far:</p>
  
  <pre><code>#!/bin/bash
  script -f -q -c"./autotelnet.sh 192.168.xxx.xxx mylogin mypassword" -a output.log &amp;
  </code></pre>
  
  <p>and this is the script for the automated telnet connection:</p>
  
  <pre><code>#!/usr/bin/expect -f
  #autotelnet.sh
  set timeout 20
  set name [lindex $argv 0]
  set port [lindex $argv 1]
  set user [lindex $argv 2]
  set password [lindex $argv 3]
  spawn telnet $name $port
  expect "Escape character is '^]'.-" #This is the actual login name prompt. 
  send "$user\r"
  expect "Password:"
  send "$password\r"
  interact
  </code></pre>
  
  <p>now if I just type "./telefonlog &amp;" it doesn't start in the background despite the ampersand in the first script, but everything gets logged as it should. (Btw, I can't get the CTRL-Z into bg command to work while in the telnet session). How can I force the expect script to stay in the background?
  Thanks in Advance!</p>