copying files

Ricardo Aráoz ricaraoz at gmail.com
Wed Aug 29 17:44:13 EDT 2007


Brian McCann wrote:
>  
>  
> <mailto:brian.mccann at viziant.net> 
> Hi Ricardo,
> 
> what do the + signs do?
>  

Add the different strings. You had 'm' and 'TEST_HOME' inside a string,
so they would be taken as characters and not variables.

>>> TEST_HOME = "/v01/test_home"
>>> m = "./lib"
>>> "cp -r " + m + " " + TEST_HOME
'cp -r ./lib /v01/test_home'   <----- This is what you want.
>>> "cp -r m TEST_HOME"
'cp -r m TEST_HOME'            <----- This is NOT what you want.

> 
> ________________________________
> 
> From: Ricardo Aráoz [mailto:ricaraoz at gmail.com]
> Sent: Wed 8/29/2007 2:51 PM
> To: Brian McCann
> Cc: python-list at python.org
> Subject: Re: copying files
> 
> 
> 
> Brian McCann wrote:
>> Hi,
>>
>> with the code below I set a variable TEST_HOME to a path and the
>> variable m to a path
>> in my current dir.
>> I have a symbolic link setting m---->lib
>> when I run the script I get no errors and the lib dir with its 20 files
>> does not get copied to /v01/test_home
>> any help would be greatly appreciated
>>
>> --Brian
>>
>> #!/usr/bin/python
>> import string
>> import os
>> import sys
>> import errno
>> import shutil
>> import tarfile
>>
>> TEST_HOME = "/v01/test_home"
>> m = "./lib"
>> os.system("cp -r m TEST_HOME")
>> #os.system("tar -cvf viziant-ingestion.tar /v01/")
>>
> 
> Sorry, meant : os.system("cp -r " + m + " " + TEST_HOME)
> 
> 
> 
> 




More information about the Python-list mailing list