I want to do the following commands in ruby.
I would recommend to view this tutorial for ssh with ruby. then make a shell script and move it to server and then execute like a single command.
create a single shell script file for example
script1 and then execute it at once instead of executing each command individually.
open file script1 using any editor.
copy all commands to
script1 (each command in new line).
script1 file should look like this
#!/bin/bash ssh example@example source ~/.profile cd to/some/folder
make this file executable using
chmod +x script
execute it in ruby like this
script1 to usr/bin to avoid "./" and then try command only
Reference for passing arguments in shell script is here.