in reply to Re: Hashes or arrays in the command line
in thread Hashes or arrays in the command line

Ok I goofed the file is static like /etc/passwd and I am taking it from a backup sub directory and the server is the variable that changes not the file itself, so it should be like:

#! /usr/bin/perl use strict; use warnings; my @SERVERS = ('sneezy','sleepy','dopey','grumpy'); my $path = "/home/backup/"; foreach my $this_server ( @SERVERS ) { `cp $path/$this_server/etc/passwd .`; }

Does this lokk right??

Replies are listed 'Best First'.
Re: Re: Re: Hashes or arrays in the command line
by EvdB (Deacon) on Nov 20, 2003 at 19:02 UTC
    It looks fine.

    If you want to do a sanity check try doing this:

    foreach my $this_server ( @SERVERS ) { my $command = "cp $path/$this_server/etc/passwd ."; warn "Will execute '$command'\n"; # system ($command); # uncomment when ready. }

    --tidiness is the memory loss of environmental mnemonics