I have been trying all day, with no luck. When I run this code, I always get an error. What is the correct way to spawn a command from a string? This should be so simple! What is wrong with tcl? I have been trying all day now. I have tried doing it lots of different ways but with no luck. Any help is GREATLY GREATLY appreciated. I have also tried with #!/usr/bin/expect -f, but that didn't work either.
When I run this, I get the error below. This is copy/pasted directly from my terminal.
spawn ssh -p 22 localhost
Bad port ' 22 localhost'
set command "-p 22 localhost"
spawn ssh [split $command]