#!/usr/local/bin/perl -w
use strict;
use Test::More tests => 5;
BEGIN { use_ok('GRID::Machine', 'is_operative') };

my $host = $ENV{GRID_REMOTE_MACHINE};

SKIP: {
    skip "Remote not operative", 4 unless $host and is_operative('ssh', $host);

    my $m = GRID::Machine->new( host => $host );

    my $f = $m->open('> tutu.txt');
    $f->print("Hola Mundo!\n");
    $f->print("Hello World!\n");
    $f->printf("%s %d %4d\n","Bona Sera Signorina", 44, 77);
    $f->close();

    $f = $m->open('tutu.txt');
    my $x = <$f>;
    is($x, "Hola Mundo!\n", "remote 1st line"); 
    
    $x = <$f>;
    is($x, "Hello World!\n", "remote 2nd line"); 

    $x = <$f>;
    is($x, "Bona Sera Signorina 44   77\n", "remote 3rd line"); 

    $f->close();

    $f = $m->open('tutu.txt');
    my $old = $m->input_record_separator(undef);
    $x = <$f>;
    $f->close();
    $old = $m->input_record_separator($old);
    like($x,qr{Hola Mundo!.*Bona Sera Signorina}s, "undef input_record_separator");


} # end SKIP block

