亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: [pexpect]如何修改sendline中的字符限制 [打印本頁]

作者: ace_fei    時(shí)間: 2012-10-18 14:52
標(biāo)題: [pexpect]如何修改sendline中的字符限制
本帖最后由 ace_fei 于 2012-10-19 14:43 編輯
  1.    
  2.     def send(self, s):

  3.         """This sends a string to the child process. This returns the number of
  4.         bytes written. If a log file was set then the data is also written to
  5.         the log. """

  6.         time.sleep(self.delaybeforesend)
  7.         if self.logfile is not None:
  8.             self.logfile.write (s)
  9.             self.logfile.flush()
  10.         if self.logfile_send is not None:
  11.             self.logfile_send.write (s)
  12.             self.logfile_send.flush()
  13.         c = os.write(self.child_fd, s)
  14.         return c
  15. def sendline(self, s=''):

  16.         """This is like send(), but it adds a line feed (os.linesep). This
  17.         returns the number of bytes written. """

  18.         n = self.send(s)
  19.         n = n + self.send (os.linesep)
  20.         return n

復(fù)制代碼
昨天用pexpect到遠(yuǎn)程服務(wù)器上執(zhí)行cmd的時(shí)候失敗,  查看log發(fā)現(xiàn)是發(fā)送的cmd長度被限制在1024內(nèi), 我一開始想可能是pexpect發(fā)送導(dǎo)致的,
不過看到pexpect包中sendline最終調(diào)用的是os.write來發(fā)送命令的,os.write是沒有字?jǐn)?shù)限制的.
我又檢查了幾遍, 最后發(fā)現(xiàn)是服務(wù)器上的命令行長度做了限制, 只接收1024字符的輸入,  差點(diǎn)錯(cuò)怪pexpect了.
作者: linux_c_py_php    時(shí)間: 2012-10-18 15:28
哪里限制了? 猜測還是有依據(jù)?
作者: ning_lianjie    時(shí)間: 2012-10-18 15:29
輸入太多的話,能不能改成從文件中讀取?
作者: ace_fei    時(shí)間: 2012-10-18 15:40
回復(fù) 2# linux_c_py_php

是我弄錯(cuò), sendline沒有限制,是我的命令行有限制導(dǎo)致的.


   
作者: ace_fei    時(shí)間: 2012-10-18 15:42
本帖最后由 ace_fei 于 2012-10-18 15:43 編輯

回復(fù) 3# ning_lianjie
sorry,是我弄錯(cuò), sendline沒有限制,是我的命令行有限制導(dǎo)致的.  

版主幫忙把這個(gè)帖子刪了吧,以免混淆視聽.  謝謝


   
作者: ning_lianjie    時(shí)間: 2012-10-18 18:38
回復(fù) 5# ace_fei

又非廣告貼,過程...刪了怪可惜的.可以重新編輯一下,與他人分享.
   




歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2