SOLVED, BUT UGLY, was Re: rsync update mixed environment

Matthew Seaman matthew at FreeBSD.org
Wed Apr 13 07:22:32 UTC 2016


On 13/04/2016 02:05, David Benfell wrote:
> Basically, I couldn't get rsync to update from within a script. No idea
> why but it looks like some way, somehow the script was the problem.
> Realizing it would be completely unreasonable to expect people on this
> list to debug my fairly gnarly script, I gave up and am using a new
> script to find the local and (with ssh) remote modification times. In
> the script that wasn't working, I'm using this new script to obtain
> those times, compare them, and scp accordingly. This works like a charm.
> 
> Yes, I'm wondering why I can go to all that trouble, get it working, and
> utterly fail to get rsync working.

So, rsync works fine if called directly from the command line, but fails
in your script?  That sounds as if you're modifying something in the
environment which is in turn causing problems for rsync(8).  The good
news is that there are only 8 variables documented as affecting rsync --
see the section 'ENVIRONMENT VARIABLES' towards the end of rsync(1).  Of
those, RSYNC_RSH, HOME and USER/LOGNAME look like the most likely
candidates.  HOME is important because that controls where ssh(1) reads
various config settings and finds ssh keys etc.  USER/LOGNAME
effectively does the same for the remote end of the connection.  I'd
also double check what PATH and IFS are set to.

Having to cook up your own mechanism to extract file modification times
is only good in the sense that it enables you to get your job done.
That's what rsync(8) really should be doing -- and the C language
interface using stat(2) is a lot more standardized than the stat(1)
wrapper program.

	Cheers,

	Matthew


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 931 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20160413/b7644c76/attachment.sig>


More information about the freebsd-questions mailing list