passing bash variables to expect script or scripting expect from inside bash
-
pass the value through the environment:
ipaddress=$(<"$file") export ipaddress /usr/bin/expect <<'EOD' spawn sudo sshfs -o StrictHostKeyChecking=accept-new cm4nxd@$env(ipaddress):/ /Volumes/ryzen-server -oallow_other -oauto_xattr -ovolname=ryzen-server # ..........................................................^^^^^^^^^^^^^^^
(edit 17 hours later) -- Note that the
'EOD'
must be quoted. That essentially single quotes the entire heredoc so that the shell does not expand Expect's variables. -
don't need the shell: read the file in expect
#!/usr/bin/env expect set fh [open /Users/cm4nxd/Library/Scripts/current.ip r] gets $fh ipaddress close $fh spawn ... user@$ipaddress ...