Scripting with User Switch Command

Thanks @Nicd,

I have implemented it as expect-script now and will try to improve it. For others with a similar problem, here is my current solution that seems to do the trick:

set username [lindex $argv 0]
set app_ip [lindex $argv 1] 
spawn ./start-iex $username

expect "iex" { send "Node.connect :\"app@$app_ip\"" }
expect "iex" { send "^G" } # this might break while copy-pasting - it is the CTRL+G command
expect -- " -->" { send "r 'app@$app_ip' \n" }
expect -- " -->" { send "c 2\n" }
expect "(app@*" { send "^G" } # see above
expect -- " -->" { send "r 'app@$app_ip' 'Elixir.IEx'\n" }
expect -- " -->" { send "c 3\n" }

interact

I have not used expect before, so if you see any unnecessary parts let me know :slight_smile:.

And if anybody knows a way to enter the user switch command mode within an elixir script, let me know.