[TriLUG] bash, variables and expect

Scott Chilcote scottchilcote at earthlink.net
Thu Jul 12 10:52:57 EDT 2007


Matthew Opoka wrote:
> All,
> 
> If you call an expect script in bash, how do you get the expect script to see the bash variables or is this possible?   I tried exporting the variables but that didn't work.
> 
> Regards,
> 
> Matthew

Hello Matthew,

Applications run from scripts with bash always inherit their 
environment.  I tried a quick test, and it worked fine for me.

I created the following two scripts:

$ cat expect-test
#!/usr/bin/expect -f
send $env(FOO)\n"
$
$cat runit
#!/bin/bash
export FOO=foo
./expect-test

After chmod +x on both of them, I execute "runit"
./runit
foo
$

I think this might be a different problem.

Good luck,

Scott C.



More information about the TriLUG mailing list