Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import sys
- #put this file in your /bin/THISFILE
- #upload files only python3
- print("mycloud v0.1")
- time.sleep(1)
- if len(sys.argv) == 4:
- FILENAME = []
- HOST = str(sys.argv[1])
- USER = str(sys.argv[2])
- PASS = str(sys.argv[3])
- ftp = FTP(HOST)
- if ftp:
- print(ftp)
- else:
- print("ERROR: Could not connect to {}".format(HOST))
- sys.exit(1)
- login = ftp.login(user=USER, passwd=PASS)
- if login:
- print(login)
- else:
- print("ERROR: Could not Login to FTP Server!")
- sys.exit(1)
- else:
- print("ERROR: FILE <ip> <username> <password>")
- sys.exit(1)
- def upload_file(FILENAME):
- for f in os.listdir(os.curdir):
- if os.path.isfile(f):
- FILENAME.append(f)
- for get_names in FILENAME:
- UPLOAD_FILE = ftp.storbinary('STOR ' + get_names, open(get_names, 'rb'))
- if UPLOAD_FILE:
- print("sucsessfully uploaded {} - {}".format(get_names,UPLOAD_FILE))
- else:
- print("ERROR: Could not upload {} - {}".format(get_names,UPLOAD_FILE))
- ftp.quit()
- upload_file(FILENAME)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement