Of course, bash cannot interpret wait commands, just as bash cannot interpret Java / Perl / Python syntax. There are several approaches.
Write the expected script as a separate program and call it from the bash script:
#!/bin/bash clear while read -u3 LINE do #... ./expect_scp.exp "$BASE_DIR" "$D_IPADDRESS" "$USERNAME" "$PASSWORD" done 3< /opt/sitelist.txt
and expect_scp.exp is
#!/usr/bin/expect set base_dir [lindex $argv 0] set remote_ip [lindex $argv 1] set username [lindex $argv 2] set password [lindex $argv 3]
You can put the expected script inside a bash script, with particular emphasis on quoting. Fortunately, single quotes are not particularly expected.
#!/bin/bash clear export BASE_DIR D_IPADDRESS USERNAME PASSWORD while read -u3 LINE do
source share