sending commands to batch

Apr 22, 2013 at 12:54 PM
Edited Apr 22, 2013 at 12:57 PM
I use renci.sshnet to run alot of commands on ubuntuo 8.4 and 12.04, and i have had some issues with the shell hanging. To get around this issue i have started echoing commands into batch.

Here is a oneliner example of forcing a reboot -f ( which alone hangs the terminal )

string cmd = @"echo Password | sudo -S echo 'sleep 2s && sudo reboot -f' | batch";

I hope this can be useful for others people like me who are not linux guru's.