open CMD, "|foo -args file" or die; print CMD "$username\n$password\n"; close CMD; die "bad exit $?" if $?;