In an expect script, I'd like to download a file and execute it. I've tried these options so far:
Attempt 1 - Simply download and execute
#!/usr/bin/expect -f
spawn wget mysite.com/file.sh
spawn /bin/sh file.sh
The /bin/sh command executes before the file finishes downloading
Attempt 2 - Pipe content to executable
#!/usr/bin/expect -f
spawn /bin/sh <(curl -s mysite.com/file.sh)
I get this error:
/bin/sh: <(curl: No such file or directory
send: spawn id exp6 not open
while executing
I tried escaping characters a few different ways
Attempt 3 - Use eval
#!/usr/bin/expect -f
spawn eval "\$(/bin/sh <\(curl -s mysite.com/file.sh\))"
This gives this error:
couldn't execute "eval": no such file or directory
while executing
I tried with and without escaping characters