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

Discussion in 'Python' started by Ê÷Éϲä»Ò, Feb 23, 2006.

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




    --
    Ê÷Éϲä»Ò
     
    Ê÷Éϲä»Ò, Feb 23, 2006
    #1
    1. Advertising

  2. =?ISO-8859-1?Q?Re=3A_=27rar=27_is_not_recognized_as_?==?ISO-8859-1?Q?an_internal_or_external_command=A3=BF=A3=BF=A3=BF?==?ISO-8859-1?Q?=A3=BF?=

    Ê÷Éϲä»Ò 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?
    >
    >
    >
    >
     
    Claudio Grondi, Feb 23, 2006
    #2
    1. Advertising

  3. =?ISO-8859-2?Q?Re=3A_=27rar=27_is_not_recognized_as_?==?ISO-8859-2?Q?an_internal_or_external_command=A3=BF=A3=BF=A3=BF?==?ISO-8859-2?Q?=A3=BF?=

    Ê÷Éϲä»Ò 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
     
    Dejan Rodiger, Feb 23, 2006
    #3
  4. On Thu, 23 Feb 2006 17:03:45 +0800, "Ê÷Éϲä»Ò" <>
    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".
    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
     
    Dennis Lee Bieber, Feb 23, 2006
    #4
  5. 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!


    --
    Ê÷Éϲä»Ò
    "Ê÷Éϲä»Ò" <> дÈëÓʼþ
    news:dtjv4r$ma1$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?
    >
    >
    >
    >
    > --
    > Ê÷Éϲä»Ò
    >
    >
     
    Ê÷Éϲä»Ò, Feb 24, 2006
    #5
  6. On Fri, 24 Feb 2006 11:36:08 +0800, "Ê÷Éϲä»Ò" <>
    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:08) [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.

    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
     
    Dennis Lee Bieber, Feb 24, 2006
    #6
  7. Ê÷Éϲä»Ò

    cn.popeye Guest

    os.chdir() ?
    thank you!

    --
    ????
    "Dennis Lee Bieber" <> ????
    news:...
    > On Fri, 24 Feb 2006 11:36:08 +0800, "Ê÷Éϲä»Ò" <>
    > 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:08) [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.
    >
    > --
    > > ============================================================== <
    > > | Wulfraed Dennis Lee Bieber KD6MOG <
    > > | Bestiaria Support Staff <
    > > ============================================================== <
    > > Home Page: <http://www.dm.net/~wulfraed/> <
    > > Overflow Page: <http://wlfraed.home.netcom.com/> <
     
    cn.popeye, Feb 24, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    376
  2. Replies:
    5
    Views:
    2,616
    suken
    Nov 13, 2006
  3. Parv G.
    Replies:
    2
    Views:
    150
    Parv G.
    Dec 8, 2006
  4. Bert Ameche
    Replies:
    8
    Views:
    149
    Pawel Zielniok
    Apr 19, 2009
  5. MoshiachNow
    Replies:
    11
    Views:
    2,903
    Sisyphus
    Sep 6, 2006
Loading...

Share This Page