Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I was trying to run following python code through terminal but something is wrong as it is producing some errors

source = ['/home/akash/', '/home/akash/code']
target_dir = '/media' 
target = target_dir + os.sep + time.strftime('%Y%m%d%H%M%S') + '.zip' 
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
if os.system(zip_command) == 0:
    print('Successful backup to', target)
else:
    print('Backup FAILED')

but when i try to run it following error appears

zip I/O error: Permission denied
zip error: Could not create output file (/media/20131019083404.zip)
Backup FAILED
share|improve this question
    
Ubuntu/linux paths do not begin with something like c:\\ or E:\\. In the linux directory system, everything starts from /, and external devices are under /media/<yourname>/<devicename>. So for example if your Documents folder is in your home directory and Code is as well, you would use ["/home/yourname/Documents", "/home/yourname/Code"] and something like '/media/yourname/YourFlashDrive' for the output dir. –  DaboRoss Oct 18 '13 at 4:50
    
i changes the source and target as you said still same error is popping up –  Akash Oct 18 '13 at 4:55
    
Can you edit your question with the new code and error? –  DaboRoss Oct 18 '13 at 23:49
    
i have edited the codes with new codes and errors –  Akash Oct 19 '13 at 3:04
    
the books i am learning from is based on python 3 but i am usinf python 2.7 can this be the problem –  Akash Oct 19 '13 at 3:14
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.