ssh admin@host "sudo /path/to/wrapper.pl" #### ... die("...") if system("/path/to/cmd1.sh")!=0; die("...") if system("/path/to/interactive-cmd-exp.pl")!=0; ...