calling tar commands

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tcurdts
    New Member
    • Jun 2007
    • 12

    #16
    Nope. The only thing I changed was getting rid of the apostrophes and now I'm back to double back-slashes in the error msg:

    IOError: [Errno 2] No such file or directory: 'C:\\WorkSpace\ \LTC\\MRLC_test \\NZT\\tmp\\NZT 070830130627200 100.tar'

    The path strings in the text file are just as you'd see them in Windows:

    C:\WorkSpace\LT C\MRLC_test\NZT \tmp\NZT0708301 30627200100.tar

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #17
      Originally posted by tcurdts
      Nope. The only thing I changed was getting rid of the apostrophes and now I'm back to double back-slashes in the error msg:

      IOError: [Errno 2] No such file or directory: 'C:\\WorkSpace\ \LTC\\MRLC_test \\NZT\\tmp\\NZT 070830130627200 100.tar'

      The path strings in the text file are just as you'd see them in Windows:

      C:\WorkSpace\LT C\MRLC_test\NZT \tmp\NZT0708301 30627200100.tar
      That appears to be a valid file name and error message. I get the same message when attempting to open a file for reading that does not exist:
      IOError: [Errno 2] No such file or directory: 'H:\\TEMP\\tems ys\\xdata9992.t xt'

      Try this on your system:[code=Python]>>> import os
      >>> os.path.isfile( r'H:\TEMP\temsy s\xdata9992.txt ')
      False
      >>> os.path.isfile( r'H:\TEMP\temsy s\xdata999.txt' )
      True
      >>>[/code]

      Comment

      • tcurdts
        New Member
        • Jun 2007
        • 12

        #18
        Sooo sorry... I had the paths wrong in the textfile; the files I was trying to hit were one level up. doh!!

        It's working beautifully. I have more development ahead but will start a new thread if/when I get stuck.

        Thanks again for all your help.

        with tail between legs,
        Thom

        Comment

        • Jach
          New Member
          • Jun 2007
          • 4

          #19
          Just coming from a slightly minimalist view, you could also opt to run this command directly through the shell/command prompt. But since you're on Windows, chances are you don't have the tar utility and if you did it wouldn't be in the Path. =P But a Linux equivalent:

          Code:
          import os
          
          f = open("path_to_list.txt")
          for line in f:
            os.system("tar -zxvf " + line)
          Note this would untar to the current directory that the script is in, and you'd have to add a path to the line unless it's already in the file.

          Comment

          Working...