[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining the type of environment entry from Perl

From: Linda Walsh
Subject: Re: Determining the type of environment entry from Perl
Date: Wed, 17 Jul 2013 11:14:45 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20100228 Thunderbird/ Mnenhy/

Ole Tange wrote:
GNU Parallel can today successfully transfer bash environment values
through ssh to the remote host:

   export FOO
   parallel --env FOO -S server 'echo $FOO' ::: bar
   That's likely because it has been trained to encode variables
in a way that the other side will unravel (decode) them as vars.
It likely, 'just', has not been taught how to transfer functions across
in a decodable way much like Arrays Hashs and Aliases are not
encoded to be exportable to child processes, right now, in Bash, but
*can* be by manually encoding them and decoding them in a
child process -- just that the utility you are using right now, doesn't
support it natively.

   I'd look at the parallel code to see how it transfers the variables,
but bash uses something like this to encode vars
(courtesy of declare  -p)
for x in a i Ar Hs
> do
> declare -p $x
> done
declare -- a="alpha"
declare -i i="23"
declare -a Ar='([0]="1" [1]="2" [2]="3")'
declare -A Hs='([one]="1" [two]="2" [three]="3" )'
To get at a function you have to use declare -f:
typeset -f f
f ()
   echo func
Though bash does keep it on one line as it is entered anymore (used to in 3.x):
f() { echo func ; }

The idea is to make it fairly easy for your remote parser to see
that something is a declare(var) or a func()...
on the other side, once you get the string, you
'eval' it, and you have your original data item.

Is that the type of thing you were wanting to know?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]