简体   繁体   English

使用telnet在QNX提示符下执行二进制文件时确定等待时间

[英]Determining wait time while executing a binary on QNX prompt using telnet

I am processing certain output binary files using sloginfo on QNX, I have used ftp/telnet/vmware to get to a point where I upload the binary from my machine to the vmware instance and then run the sloginfo command. 我正在QNX上使用sloginfo处理某些输出二进制文件,我已经使用ftp / telnet / vmware达到了将二进制文件从计算机上载到vmware实例,然后运行sloginfo命令的地步。 The issue is that binary files which need to be processed are of inconsistent size (ranging from 50mb to 200mb), and the time needed to process each of these files is different, thus making it impossible to determine the wait/sleep time required. 问题在于,需要处理的二进制文件大小不一致(从50mb到200mb),并且处理每个文件所需的时间不同,因此无法确定所需的等待/睡眠时间。

I need to know if sloginfo returns a value which can be used as a flag. 我需要知道sloginfo是否返回可以用作标志的值。 I tried using tn.read_until(), without getting desired results. 我尝试使用tn.read_until(),但未获得期望的结果。

#
 import os, sys, telnetlib, time from ftplib import FTP def upload(ftp, filed): ext = os.path.splitext(filed)[1] if ext in (".txt", ".htm", ".html"): ftp.storlines("STOR " + filed, open(filed)) else: ftp.storbinary("STOR " + filed, open(filed, "rb"), 1024) def gettext(ftp, filename, outfile=None): # fetch a text file if outfile is None: outfile = sys.stdout # use a lambda to add newlines to the lines read from the server ftp.retrlines("RETR " + filename, lambda s, w=outfile.write: w(s+"\\n")) if __name__ == '__main__': dbfile = "LOG1" nonpassive = False remotesite = '192.168.0.128' ftp_port = '21' tel_port = '23' password = 'root' ftp = FTP() ftp.connect(remotesite, ftp_port) ftp.login('root','root') print 'Uploading the Log file... Please wait...' upload (ftp, dbfile) print 'File Uploaded Successfully...' tn = telnetlib.Telnet(remotesite, tel_port) tn.read_until("login: ") tn.write('root' + "\\n") if password: tn.write(password + "\\n") tn.write("sloginfo LOG1 >> LOG1.txt\\n") **#need to get more control on this sleep time** time.sleep(300) print 'Downloading text file...' gettext(ftp, "LOG1.txt", open(r'LOG1.txt','wb')) ftp.close() tn.close() 

tn.write(“ sloginfo LOG1 >> LOG1.txt \\ n”)使用tn.write('sloginfo'+ strdbfile +'>>'+ strdbfiletxt +'; echo Done!\\ n')修改了以上注释,并且已解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM