Score:0

include variable ( string ) in rsync cmd

us flag

My question is quite specific and relates to using rsync within a python script, an os command where I would need to include a variable ( string ) containing an ip address. The local ip address is changing on regular basis. I'm updating and checking for change in iphost. Below follows part of the python code:

iphost = '10.0.0.121'
os.system("rsync -ar -e  'ssh -p 900'  /local/path/to/gnumeric.file  pi@iphost:/remote/path/to/gnumeric.file")

How should I include iphost in the rsync command. Obliviously it doesn't work the way I'm using it in the code above. I think you see my point.

hr flag
Consider using [subprocess](https://docs.python.org/3/library/subprocess.html) instead - that will allow you to construct a proper argument *array*, which will make it easier to insert your variable in the right place.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.