欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

expect中\(zhòng)t和\n區(qū)別是什么

本篇內(nèi)容介紹了“expect中\(zhòng)t和\n區(qū)別是什么”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

目前累計(jì)服務(wù)客戶近1000家,積累了豐富的產(chǎn)品開發(fā)及服務(wù)經(jīng)驗(yàn)。以網(wǎng)站設(shè)計(jì)水平和技術(shù)實(shí)力,樹立企業(yè)形象,為客戶提供成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、網(wǎng)站策劃、網(wǎng)頁設(shè)計(jì)、網(wǎng)絡(luò)營銷、VI設(shè)計(jì)、網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。創(chuàng)新互聯(lián)公司始終以務(wù)實(shí)、誠信為根本,不斷創(chuàng)新和提高建站品質(zhì),通過對(duì)領(lǐng)先技術(shù)的掌握、對(duì)創(chuàng)意設(shè)計(jì)的研究、對(duì)客戶形象的視覺傳遞、對(duì)應(yīng)用系統(tǒng)的結(jié)合,為客戶提供更好的一站式互聯(lián)網(wǎng)解決方案,攜手廣大客戶,共同發(fā)展進(jìn)步。

spawn后 send 最后都追加一個(gè)回車符\r。因?yàn)檫@是程序之間的交互,用的是回車。

但是沒有spawn的情況下,send后面追加的是\n。這是方便輸出到終端的操作。

參考:

expect "hi\n"
send "hello there!\n"

I typed the string hi and then pressed return. My input matched the pattern " hi\n ". Ideally, a return would be matched with " \r "; however, the UNIX terminal driver translates a return to " \n ".2 As you will see later on, it is rarely necessary to have to worry about this mapping because most of Expect's interactions occur with programs not users, and programs do not "press return". Nonetheless, it is occasionally useful to expect input from people.Plus, it is much easier to experiment with Expect this way.

我輸入的字符串hi,然后按下回車。我的輸入匹配模式“hi\n”。理想情況下,回車與“\r”相匹配; 然而,UNIX終端驅(qū)動(dòng)將回車轉(zhuǎn)換成"\n"。正如你將在后面看到,很少需要擔(dān)心這個(gè)映射,因?yàn)榇蟛糠諩xpect的交互發(fā)生在程序中而不是用戶側(cè),程序并不”按回車“。盡管如此,在期望從用戶輸入時(shí)這偶爾是有用的,另外,這是很容易使用Expect進(jìn)行實(shí)驗(yàn)。

expect "Name"
send "anonymous\r"
expect "Password:"
send "don@libes.com\r"
expect "ftp> "

It is a common mistake to terminate send commands to a process followed by \n . In this context, \n denotes a linefeed character. You do not interactively end lines with a linefeed. So Expect must not either. Use " \r ".

這是一個(gè)常見的錯(cuò)誤去使用\n來終止關(guān)聯(lián)到一個(gè)進(jìn)程的send命令。在這種情況下,\n表示換行字符。你不會(huì)使用換行符結(jié)束一行。所以Expect來不會(huì)。這里使用“\r”。

Contrast this to what I was doing earlier -- sending to a user, or rather, standard output. Such strings were indeed terminated with a \n . In that context, the \n denotes a newline. Because standard output goes to a terminal, the terminal driver translates this to a carriage-return linefeed sequence.
Similarly, when reading lines from a program that would normally appear on a terminal, you will see the carriage-return linefeed sequence. This is represented as \r\n in an expect pattern.

將這個(gè)和我之前做的相對(duì)比 - 發(fā)送給用戶,或者更確切地說,標(biāo)準(zhǔn)輸出。這樣的字符串確實(shí)是使用\n來終止的。在這種情況下,\n表示新的行。由于標(biāo)準(zhǔn)輸出到終端,終端驅(qū)動(dòng)將其轉(zhuǎn)換成回車換行序列。

同樣,在終端上從程序讀入行的時(shí)候,你會(huì)看到回車換行序列。這表示為Expect模式中的\r\n。

This may seem confusing at first, but it is inherent in the way UNIX does terminal I/O and in the representation of characters and newlines in strings. The representation used by Tcl and Expect is common to the C language and most of the UNIX utilities. I will have more to say on the subject of newlines and carriage returns in .


第一眼看起來似乎是令人困惑的,但它是固有的UNIX處理終端I/O的方式,和字符串中的字符和換行符的表示方式。使用Tcl和Expect的表示是和C語言和大部分的UNIX工具是共通的。我將在換行和回車的主題中做更多的闡述。

“expect中\(zhòng)t和\n區(qū)別是什么”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

分享標(biāo)題:expect中\(zhòng)t和\n區(qū)別是什么
文章源于:http://chinadenli.net/article42/gjogec.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、做網(wǎng)站網(wǎng)站改版、動(dòng)態(tài)網(wǎng)站Google、定制網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)