Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > 'rar' is not recognized as an internal or external command

Reply
Thread Tools

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

 
 
ϲ
Guest
Posts: n/a
 
      02-23-2006

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




--
ϲ


 
Reply With Quote
 
 
 
 
Claudio Grondi
Guest
Posts: n/a
 
      02-23-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?
>
>
>
>

 
Reply With Quote
 
 
 
 
Dejan Rodiger
Guest
Posts: n/a
 
      02-23-2006
ϲ 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"
--
Dejan Rodiger - PGP ID 0xAC8722DC
Delete wirus from e-mail address
 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      02-23-2006
On Thu, 23 Feb 2006 17:03:45 +0800, "ϲ" <(E-Mail Removed)>
declaimed the following in comp.lang.python:


> 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".
--
> ================================================== ============ <
> http://www.velocityreviews.com/forums/(E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <

 
Reply With Quote
 
ϲ
Guest
Posts: n/a
 
      02-24-2006
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!


--
ϲ
"ϲ" <(E-Mail Removed)> дʼ
news:dtjv4r$ma1$(E-Mail Removed)99.com...
>
> '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?
>
>
>
>
> --
> ϲ
>
>



 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      02-24-2006
On Fri, 24 Feb 2006 11:36:08 +0800, "ϲ" <(E-Mail Removed)>
declaimed the following in comp.lang.python:

> 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:0 [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.system("dir /w")

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
>>> os.system("cd e:\\userdata")

0
>>> os.system("dir /w")

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
>>> os.chdir("e:\\userdata")
>>> os.system("dir /w")

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.

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

 
Reply With Quote
 
cn.popeye
Guest
Posts: n/a
 
      02-24-2006
os.chdir() ?
thank you!

--
????
"Dennis Lee Bieber" <(E-Mail Removed)> ????
news:(E-Mail Removed)...
> On Fri, 24 Feb 2006 11:36:08 +0800, "ϲ" <(E-Mail Removed)>
> declaimed the following in comp.lang.python:
>
> > 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:0 [MSC v.1200 32 bit (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import os
> >>> os.system("dir /w")

> 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
> >>> os.system("cd e:\\userdata")

> 0
> >>> os.system("dir /w")

> 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
> >>> os.chdir("e:\\userdata")
> >>> os.system("dir /w")

> 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.
>
> --
> > ================================================== ============ <
> > (E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> > (E-Mail Removed) | Bestiaria Support Staff <
> > ================================================== ============ <
> > Home Page: <http://www.dm.net/~wulfraed/> <
> > Overflow Page: <http://wlfraed.home.netcom.com/> <



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'localconfig' is not recognized as an internal or external command pkrishna.82 Software 1 12-31-2010 04:35 AM
'ipconfig' is not recognized as an internal or external command, Peter Computer Support 8 08-27-2008 09:11 AM
'subst' is not recognized as an internal or external command,operable program or batch file. ME Computer Information 0 10-16-2007 03:53 PM
Ping is not recognized as an internal or external command... =?Utf-8?B?SmFtZXM=?= Wireless Networking 1 11-10-2004 08:40 PM
Ping is not recognized as an internal or external command... =?Utf-8?B?SmFtZXM=?= Wireless Networking 0 11-10-2004 05:29 PM



Advertisments