in reply to Re^2: Comparing localtime to a remote file's modification time.
in thread Comparing localtime to a remote file's modification time.

When Perl sees \' in a string literal, it places just ' in the string, so you haven't changed anything.

You seem to have missed half of my comment.
I didn't suggest that you escape the 1st and 2nd ' with \.
I didn't suggest that you escape all the ' with \.
I suggested that you escape the 2nd and 3rd ' with \\.

$FileTime = `ssh $ServerName 'perl -e \\'(stat($FP_RemoteFile))[9];\\''`;
executes
ssh $ServerName 'perl -e \'(stat(...))[9];\''
which executes
perl -e '(stat(...))[9];'
on the remote machine if sh behaves as I think it does.

Update: stat($FP_RemoteFile) is also wrong. You need to convert the contents of $FP_RemoteFile into a Perl literal, then you must escape it for sh.

Replies are listed 'Best First'.
Re^4: Comparing localtime to a remote file's modification time.
by baerlun (Initiate) on Oct 24, 2006 at 16:41 UTC
    You're right, of course (about both: my lack of reading comprehension and the explanation). I guess thinking it through should've worked for me. Thanks again.