我有一个带有 .gz 和文件名的包(xxxxxxxxxxxx_PARSERxxxxx.tar.gz)扩展名放置在远程目录中,比如 1.1.1.1(应该是作为变量的输入),我目前正在从机器运行脚本,比如 2.2。 2.2,我需要将包放在机器 3.3.3.3 中(应该作为变量输入),为此准备了一个脚本,但它不起作用,请帮助我,
这是我到目前为止编写的代码(不工作):
#!/usr/bin/python
#ftp.py
import sys
import telnetlib
from ftplib import FTP
import os
def handleDownload(block):
file.write(block)
print ".",
hstip= raw_input('Enter the hstip: ') #ip of the machine where packages ae placed
uid = raw_input('Enter the username: ') #uid os the machine whr packages are placed
pwd = raw_input('Enter the user password: ') #pwd of hte machine where packages are palced
path = raw_input('Enter the path where packages are present: ') #path for the packages.
rmthstip= raw_input('Enter the hstip: ') #ip of the machine where packages to be placed
rmtuid = raw_input('Enter the username: ') #uid os the machine whr packages to be placed
rmtpwd = raw_input('Enter the user password: ') #pwd of hte machine where packages to be palced
cwd = os.getcwd()
os.chdir(cwd)
logout = 'parser files downloaded succesfully'
tn = telnetlib.Telnet(rmtip)
tn.read_until("login: ")
tn.write(rmtuid + "\n")
tn.read_until("Password:")
tn.write(rmtpwd + "\n")
ftp=FTP(hstip,uid,pwd)
print 'Logging in.'
ftp.login(uid,pwd)
ftp.cwd(path)
parserfile = 'find . -name "*PARSER*.gz"'
filenm = os.system(parserfile)
print filenm
ftp.retrbinary(' RETR ', 'filenm', logout )
ftp.quit()
tn.close()