Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #-*- coding:Utf-8 -*-
- import os
- import time
- import sys
- import subprocess
- source = []
- print sys.argv
- for i in range(len(sys.argv)):
- source.append(sys.argv[i])
- source.remove(source[0])
- source.remove(source[0])
- print source
- print sys.argv[1]
- target_dir = sys.argv[1]
- today = target_dir + os.sep + time.strftime('%Y%m%d')
- now = time.strftime('%H%M%S')
- if sys.argv[1][0] == "/" :
- print sys.argv[1] + "local"
- if not os.path.exists(today):
- os.mkdir(today) # cree le repertoire
- target = today + os.sep + now + '.zip'
- zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
- if os.system(zip_command) == 0:
- print 'Sauvegarde reussie vers', target
- else:
- print 'Echec de la sauvegarde'
- else :
- home = os.path.expanduser('~')
- print home
- print sys.argv[1] + "network"
- target_dir = "%s/Bureau" % home
- print target_dir
- today = target_dir + os.sep + time.strftime('%Y%m%d')
- now = time.strftime('%H%M%S')
- if not os.path.exists(today):
- os.mkdir(today) # cree le repertoire
- target = today + os.sep + now + '.zip'
- print target
- zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
- if os.system(zip_command) == 0:
- print 'Sauvegarde local reussie vers', target
- else:
- print 'Echec de la sauvegarde local'
- target_dir = sys.argv[1]
- remote_path = "/home/hatim/Bureau/"
- print remote_path
- password = "444444"
- print today
- script = "/home/ismail/Bureau/SaveProg/scpmotdepasse1.sh"
- params = [script, today, remote_path, target_dir, password]
- cmd = " ".join(params)
- print(cmd)
- os.system(cmd)
Add Comment
Please, Sign In to add comment