Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Ê÷Éϲä»Ò
Guest
 
Posts: n/a
#1: Feb 23 '06

'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!


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?




--
Ê÷Éϲä»Ò



Claudio Grondi
Guest
 
Posts: n/a
#2: Feb 23 '06

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


Ê÷Éϲä»Ò wrote:[color=blue]
> '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![/color]
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[color=blue]
>
>
> 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?
>
>
>
>[/color]
Dejan Rodiger
Guest
 
Posts: n/a
#3: Feb 23 '06

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


Ê÷Éϲä»Ò said the following on 23.02.2006 10:03:[color=blue]
> rar_cmd = r'"D:\Program Files\WinRAR\rar.exe" a -idcdp %s %s' % (target,' '.join(source))[/color]

You can't cd to d:\Program Files\WinRAR and then call rar

You have to call rar with full path.

from subprocess import *
retcode = call([r'"D:\Program Files\WinRAR\rar.exe"', 'a', '-idcdp', target,
' '.join(source)])
if retcode == 0:
print "everything OK"
--
Dejan Rodiger - PGP ID 0xAC8722DC
Delete wirus from e-mail address
Ê÷Éϲä»Ò
Guest
 
Posts: n/a
#4: Feb 24 '06

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


thank everyone!!!

the code:

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 = "D:\\Progra~1\\WinRAR\\rar.exe a -idcdp %s %s" % (target,'
'.join(source))
print rar_cmd
if os.system(rar_cmd) == 0:
print 'Successful backup to',target
else:
print 'Backup Failed!'

thanks again!


--
Ê÷Éϲä»Ò
"Ê÷Éϲä»Ò" <zhangchao19@hotmail.com> дÈëÓʼþ
news:dtjv4r$ma1$1@news.cn99.com...[color=blue]
>
> '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!
>
>
> 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[/color]
OK[color=blue]
> Adding e:\temp\Code\Code\.project[/color]
OK[color=blue]
> Adding e:\temp\Code\Code\common\Code.class[/color]
OK[color=blue]
> Adding e:\temp\Code\Code\common\Code.java[/color]
OK[color=blue]
> Adding e:\temp\Code\Code\common[/color]
OK[color=blue]
> Adding e:\temp\Code\Code[/color]
OK[color=blue]
> Adding e:\temp\Code[/color]
OK[color=blue]
> Adding e:\temp\domains\examples.jar[/color]
OK[color=blue]
> Adding e:\temp\domains\medrec.jar[/color]
OK[color=blue]
> Adding e:\temp\domains\wls.jar[/color]
OK[color=blue]
> Adding e:\temp\domains\wlw.jar[/color]
OK[color=blue]
> Adding e:\temp\domains[/color]
OK[color=blue]
>
> D:\Program Files\WinRAR>
>
>
>
> why?
>
>
>
>
> --
> Ê÷Éϲä»Ò
>
>[/color]


cn.popeye
Guest
 
Posts: n/a
#5: Feb 24 '06

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


os.chdir() ?
thank you!

--
????
"Dennis Lee Bieber" <wlfraed@ix.netcom.com> ????
news:2n6tv1h0hgdp3ajua4vb9eaipv3pccf9p0@4ax.com...[color=blue]
> On Fri, 24 Feb 2006 11:36:08 +0800, "Ê÷Éϲä»Ò" <zhangchao19@hotmail.com>
> declaimed the following in comp.lang.python:
>[color=green]
> > thank everyone!!!
> >[/color]
> I'd had to run to work so couldn't test, but... notice this:
>
>
> C:\Documents and Settings\Dennis Lee Bieber>python
> ActivePython 2.3.5 Build 236 (ActiveState Corp.) based on
> Python 2.3.5 (#62, Feb 9 2005, 16:17:08) [MSC v.1200 32 bit (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.[color=green][color=darkred]
> >>> import os
> >>> os.system("dir /w")[/color][/color]
> Volume in drive C is System
> Volume Serial Number is 0487-A514
>
> Directory of C:\Documents and Settings\Dennis Lee Bieber
>
> [.] [..] [.eclipse]
> [.gps] [.mysqlcc] [.netbeans]
> [.refactorit] [.refactorit_please_delete_me]
> [Application Data]
> [Desktop] Eudora.lnk [Favorites]
> [Start Menu] [workspace]
> 1 File(s) 820 bytes
> 13 Dir(s) 22,481,092,608 bytes free
> 0[color=green][color=darkred]
> >>> os.system("cd e:\\userdata")[/color][/color]
> 0[color=green][color=darkred]
> >>> os.system("dir /w")[/color][/color]
> Volume in drive C is System
> Volume Serial Number is 0487-A514
>
> Directory of C:\Documents and Settings\Dennis Lee Bieber
>
> [.] [..] [.eclipse]
> [.gps] [.mysqlcc] [.netbeans]
> [.refactorit] [.refactorit_please_delete_me]
> [Application Data]
> [Desktop] Eudora.lnk [Favorites]
> [Start Menu] [workspace]
> 1 File(s) 820 bytes
> 13 Dir(s) 22,481,092,608 bytes free
> 0[color=green][color=darkred]
> >>> os.chdir("e:\\userdata")
> >>> os.system("dir /w")[/color][/color]
> Volume in drive E is Data
> Volume Serial Number is 2626-D991
>
> Directory of e:\userdata
>
> [.] [..] [Dennis Lee Bieber]
> DummyQuicken.IDX
> DummyQuicken.QDF DummyQuicken.QEL DummyQuicken.QPH [Root]
> 4 File(s) 316,184 bytes
> 4 Dir(s) 307,433,058,304 bytes free
> 0[color=green][color=darkred]
> >>>[/color][/color]
>
> Notice how using os.system() to do a "cd" doesn't "stick"... But if
> you used os.chdir() instead, THAT setting carries over to subsequent
> os.system() calls.
>
> --[color=green]
> > ================================================== ============ <
> > wlfraed@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
> > wulfraed@dm.net | Bestiaria Support Staff <
> > ================================================== ============ <
> > Home Page: <http://www.dm.net/~wulfraed/> <
> > Overflow Page: <http://wlfraed.home.netcom.com/> <[/color][/color]


Closed Thread