in reply to Ssh Keys

  1. Useless use of back ticks, try system or exec.

    ...and so your test is probably not doing what you think it is. spoke too soon.

    Or maybe you intended to discard the output as a side-effect, do it explicitly with /dev/null or some such.

  2. Why not use the environment variables directly?
  3. What if I don't have a $HOME? ;-)

UPDATE:

#Globals are bad mojo my $remotemachine = $ARGV[0]; # see if keys exist if (-e !"/$home/.ssh/id_dsa.pub"){ system('ssh-keygen', '-t', 'dsa'); } #Only use semi-colon's after do{} blocks. system('scp', "/$ENV{HOME}/.ssh/id_dsa.pub, "$remotemachine://home/$EN +V{USER}/.ssh/authorized_keys2"); system('ssh-agent', q(sh -c 'ssh-add < /dev/null && bash')); exec('ssh', $remotemachine); #exit (0); #That's the default

--
In Bob We Trust, All Others Bring Data.

Replies are listed 'Best First'.
Re^2: Ssh Keys
by j^2 (Novice) on Nov 28, 2005 at 20:50 UTC
    Ah neat! thanks for your help. Can i ask why global vars are "bad mojo"?

      Globals are bad in just about any programming language because it's so easy to tinker with the value wherever you are in the code. The flipside of that is, when Something Bad happens in the code, you have no idea where that global is being changed.

      A better coding style involves limiting a variable to the smallest possible scope, like within a small piece of code, such as within an object definition, where you can control the setters and getters of the object's attributes.

      And if you need a rule, it's probably something like "Global variables should be the exceptions, not the rule".

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds