Re: 'rar' is not recognized as an internal or external command£¿£¿£¿£¿

Claudio Grondi claudio.grondi at freenet.de
Thu Feb 23 05:25:32 EST 2006


Ê÷Éϲä»Ò wrote:
> 'rar' is not recognized as an internal or external command,
> operable program or batch file.
> 
> 
> import os
> import time
> source = [r'e:\temp\code',r'e:\temp\domains']
> target_dir = r'e:\temp\bak'
> target = target_dir+time.strftime('%Y%m%d%H%M%S')+'.rar'
> rar_cmd = "rar a -idcdp %s %s" % (target,' '.join(source))
> print rar_cmd
> if os.system(r'cd D:\Program Files\WinRAR') == 0:
>   if os.system(rar_cmd) == 0:
>     print 'Successful backup to',target
>   else:
>     print 'Backup Failed!'
> else:
>   print 'FAILED!!!'
> 
> 'rar' is not recognized as an internal or external command,
> operable program or batch file.
> 
> rar a -idcdp e:\temp\bak20060222191139.rar e:\temp\code e:\temp\domains
> Backup Failed!
It is always a good idea to use full path file location specs like:
rar_cmd = r"D:\Program Files\WinRAR\rar.exe a -idcdp %s %s" % (target,' 
'.join(source))
.
Have not tested it, but I suppose it will do the job.

Claudio
> 
> 
> but.........................
> 
> D:\>cd D:\Program Files\WinRAR
> 
> D:\Program Files\WinRAR>rar a -idcdp e:\temp\bak20060222191139.rar
> e:\temp\code
> e:\temp\domains
> 
> Creating archive e:\temp\bak20060222191139.rar
> 
> Adding    e:\temp\Code\Code\.classpath                                    OK
> Adding    e:\temp\Code\Code\.project                                      OK
> Adding    e:\temp\Code\Code\common\Code.class                             OK
> Adding    e:\temp\Code\Code\common\Code.java                              OK
> Adding    e:\temp\Code\Code\common                                        OK
> Adding    e:\temp\Code\Code                                               OK
> Adding    e:\temp\Code                                                    OK
> Adding    e:\temp\domains\examples.jar                                    OK
> Adding    e:\temp\domains\medrec.jar                                      OK
> Adding    e:\temp\domains\wls.jar                                         OK
> Adding    e:\temp\domains\wlw.jar                                         OK
> Adding    e:\temp\domains                                                 OK
> 
> D:\Program Files\WinRAR>
> 
> 
> 
> why?
> 
> 
> 
> 



More information about the Python-list mailing list