#!/usr/bin/perl open(my $ssh, "| ssh host"); print $ssh "ssh host2\n"; print $ssh "echo Hallo\n"; close($ssh) or die "$!";