TTL学習



Ttl Learning



++++++++++++++++++++++++++++++++++++++++++++ tera term connection script The following is the way to define variables Here we set the host name Host user user1 password password1 ++++++++++++++++++++++++++++++++++++++++++++ Host = '192.***.***.***' User1 = '*******' Password1 = '******' Ini = 'TERATERM.INI' Prompt1 = '$' PromptPW = 'suDyzVs83y' Df = 'df' set a character Cmd to an empty string strconcat is a spliced ​​string, we can see a series of stitching below, The final effect of Cmd looks like this: '192.***.***.*** /ssh /auth=password /user=username /passwd= passwd' Cmd = '' strconcat Cmd Host strconcat Cmd ' /ssh /1 /auth=password' strconcat Cmd ' /user=' strconcat Cmd User1 strconcat Cmd ' /passwd=' strconcat Cmd Password1 strconcat Cmd ' /f=' strconcat Cmd Ini connect connection command (Figure 1) that is: connect '192.***.***.*** /ssh /auth=password /user=username /passwd= passwd' connect Cmd wait (waiting for a matching string to appear) Figure 2 sendln (transfer line after sending a line of characters) waiting for the $ symbol of bash wait '$' connected via ssh sendln 'ssh root@xxxxx***.***.***.***' here is the ':' waiting for the password to be entered wait ':' enter password sendln '****' Login successfully switched to the corresponding directory Figure 3 wait '$' sendln 'cd /home/***' wait '$' This is still connected to another server through ssh, the reason why the directory is switched above is because this directory project has the private key that does not use password login when we ssh connect. If you are interested, you can learn about the ssh protocol command. sendln 'ssh -i ***_private.pem root@xxxxx***.***.***' The following statements are also waiting for a match ':' to enter the password. wait ':' The password here is empty Figure 4 sendln '' wait ':' sendln '*****' Switch root user Figure 5 wait '$' sendln 'su -' wait ':' sendln '*****' The reason why I wait for '#' is because we switched to root above, so match # wait '#' Switch catalogue Figure 6 sendln 'cd /var/www/www.****.jp.net' ++++++++++++++ Summary ++++++++++++++++++++ When we configure the ttl script to connect automatically, we have a hard time Correct, it doesn't matter, we can according to our actual situation, first connect to the first server, then it's actually very simple, just In our usual command to switch to the target server is used here wait and sendln match, We don't necessarily all wait '$' so that we arrived at this Step, what the system displays, is ':' then wait ':', is '#' then wait '#' and then write us on the command line command through sendln, When we finish a part of ttl writing, we can try to connect Take a look, see what went wrong, and then modify it. Like, step by step ++++++++++++++++++++++++++++++++++++++++++++ restoresetup Ini

私たちが通常使用できる基本は、これらの単純な文法です。より複雑なものについては、公式ウェブサイトにアクセスして学ぶことができます。以下は、それ自体に対応する上記のスクリプト実行のタイミング図です。

---------------------



この記事は、pfm685757のCSDNブログからのものです。全文アドレスについては、次をクリックしてください。 https://blog.csdn.net/pfm685757/article/details/64503262?utm_source=copy