Advertisement
Guest User

Untitled

a guest
Aug 14th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import pysftp;
  2. #import ftplib;
  3. import zipfile;
  4. #import pickle;
  5. import sys;
  6. import paramiko;
  7. import os;
  8. import subprocess
  9. import shlex
  10.  
  11. # Used to convert MFT files to CSV format
  12.  
  13. import analyzeMFT
  14.  
  15. srv=pysftp.Connection(’10.0.01’,username=‘ftp’,private_key_pass=‘password’,private_key=‘/home/ace/id_rsa')
  16.  
  17. #List the files in the current directory
  18.  
  19. #print os.getcwd();
  20. #Get the readme file
  21.  
  22. srv.chdir(‘/home/download’)
  23. remote_file = sys.argv[0]
  24. remote_file = raw_input("Enter LR zip file name: ")
  25. response = srv.get(remote_file)
  26.  
  27. print(remote_file)
  28.  
  29. dir_name = ‘/home/download’
  30. extension = ".zip"
  31. os.chdir(dir_name) # change directory from working dir to dir with files
  32.  
  33. for item in os.listdir(dir_name): # loop through items in dir
  34. if item.endswith(extension): # check for ".zip" extension
  35. file_name = os.path.abspath(item) # get full path of files
  36. zip_ref = zipfile.ZipFile(file_name) # create zipfile object
  37. zip_ref.extractall(dir_name) # extract file to dir
  38. zip_ref.close() # close file
  39. os.remove(file_name) # delete zipped file
  40.  
  41.  
  42.  
  43. # Convert LR from MFT to CSV File format
  44.  
  45. subprocess.call(shlex.split('./analyzeMFT.py -f filename.mft'] -o ['filename.csv']'))
  46.  
  47. srv.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement