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

Ê

Ê÷Éϲä»Ò

'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?
 
C

Claudio Grondi

Ê÷Éϲä»Ò said:
'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
 
D

Dejan Rodiger

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

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"
 
D

Dennis Lee Bieber

if os.system(r'cd D:\Program Files\WinRAR') == 0:

You created a shell, performed a "cd" in that shell, and then the
shell went away.
if os.system(rar_cmd) == 0:

You now create another shell, which knows nothing about the previous
"cd".
--
 
Ê

Ê÷Éϲä»Ò

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

Dennis Lee Bieber

thank everyone!!!
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. 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 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 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
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.

--
 
C

cn.popeye

os.chdir() ?
thank you!

--
????
Dennis Lee Bieber said:
thank everyone!!!
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.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
0Volume 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
0Volume 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
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.

--
============================================================== <
(e-mail address removed) | Wulfraed Dennis Lee Bieber KD6MOG <
(e-mail address removed) | Bestiaria Support Staff <
============================================================== <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top