Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: Get remote file TimeStamp

by Saved (Beadle)
on Mar 01, 2012 at 11:21 UTC ( [id://957172]=note: print w/replies, xml ) Need Help??


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

This works well, and since I cannot add modules, it is preferred. My last problem which I am still working on is that the "aimuat" in the name argument of the ssh, and farther on in the file name needs to be a variable.

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

Thanx for all your help, it is much appreciated

Replies are listed 'Best First'.
Re^5: Get remote file TimeStamp
by Eliya (Vicar) on Mar 01, 2012 at 12:49 UTC

    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'.

      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"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://957172]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-04-24 10:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found