On Tue, Sep 18, 2012 at 07:15:28AM -0700, jlm17 wrote:
> I'm probably doing something obviously wrong, but when I try to set an
> environment variable, it does not take:
>
> [root@host1 ~]# pssh -P -v -p 1 -H "host1 host2" "export foo=\"hi\"; echo
> \"<$foo>\""
> host1: <>
> [1] 09:59:35 [SUCCESS] host1
> host2: <>
> [2] 09:59:36 [SUCCESS] host2
The $foo is actually getting substituted by Bash on your local machine
before pssh even runs. Since the variable isn't defined, $foo gets
expanded to the empty string. The solution is to tell Bash not to
expand $foo by either:
1) Using single quotes:
[root@host1 ~]# pssh -P -v -p 1 -H "host1 host2" 'export foo=\"hi\"; echo
\"<$foo>\"'
2) Escaping the $:
[root@host1 ~]# pssh -P -v -p 1 -H "host1 host2" "export foo=\"hi\"; echo
\"<\$foo>\""
This sort of problem can be really "fun" sometimes.
--
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868