in reply to sending variables between .pl over remote machines

  1. Have the remote script update a hash with the variable name and its value
  2. Use Data::Dumper to dump the hash to STDOUT
  3. Capture STDOUT from the remote m/c (as you're already doing)
  4. eval the captured text (Data::Dumper output) to locally recreate a hash
???

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: sending variables between .pl over remote machines
by steelcarn99 (Initiate) on Aug 11, 2009 at 13:50 UTC
    How do you go about capturing the STDOUT?

    (In my remote script)

    print $lastrecord;

    This gets printed to the command line on my local machine. Is there a special variable that I can call that holds this value?
      A few more details would help, but I'm assuming your local script has something along the lines of `ssh $remote_host $cmd`;, if so, then modifying this to read my $out = `ssh $remote_host $cmd`;` will capture STDOUT, from the remote host, into $out.

      Subsequently, assuming a hash was dumped at the remote host, eval $out;die $@ if $@; should create $VAR1 as a hash ref. locally.

      A user level that continues to overstate my experience :-))
        I set this line to a variable like you stated above, however I am not dumping any hash. I thought that printing the $out variable would return the same value as the system command.

        my $out = system('ssh $host $cmd'); print $out;