in reply to Re^4: Get remote file TimeStamp
in thread Get remote file TimeStamp

There are several ways to solve this.  For one, you could use the interpolating qq operator (acts like double quotes), but then you'd have to double escape things...  Personally, I would rather use concatenation, which isn't pretty either, but somewhat easier to read (IMHO):

foreach my $SYSTEM (qw(ifeuu1 ifcau1 ifcaa1 mifuat aimuat timeuat)) { my $cmd = 'ssh -q '.$SYSTEM.q| perl -e \'print +\( stat \( \"Envs_ +|.$SYSTEM.q|.xml\" \)\)\[9\]\;\'|; print `$cmd`; }

Also note that I used qw() for the hostname list, because what you had were barewords, usage of which is generally discouraged.  qw(foo bar baz) is just a short form of saying 'foo', 'bar', 'baz'.

Replies are listed 'Best First'.
Re^6: Get remote file TimeStamp
by Saved (Beadle) on Mar 01, 2012 at 13:54 UTC

    Thank You. Having these alternatives in my toolbox is comforting, and useful. I tried putting a Place Holder SYSTEM in the cmd , and then doing a substitution. It seems to work also. Your help is valuable.

    foreach my $SYS (qw(ifeuu1 ifcau1 ifcaa1 mifuat aimuat timeuat)) { $cmd=q|ssh -q SYSTEM perl -e \'print +\( stat \( \"Envs_SYSTEM.xml\" \ +)\)\[9\]\;\'|; $cmd =~ s/SYSTEM/$SYS/g ; print "$SYS:" . `$cmd` . "\n"; }