FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
tino_p
Staff
Staff
Article Id 342190
Description This article describes some tips for using Notepad++ to avoid repeated tasks when creating a TTL script.
Scope FortiGate, TeraTerm.
Solution

A long list of commands is needed in a TTL script. For example:

 

get system status
fnsysctl date
get sys perf status
diag sys session stat
diag hardware sysinfo memory
diag hardware sysinfo slab
diag sys vd list | grep fib
diagnose sys mpstat 1 5
diag sys top-all 2 30 10
diag sys top-mem 30
diag sys top-fd 30

 

The objective is to include them in the TTL script, in the format like this:

 

sendln 'get system status'

pause 2
sendln 'fnsysctl date'

pause 2
sendln 'get sys perf status'

pause2

 

And so on.

 

By using the following steps in the Find/Replace function on Notepad++, there is no need to edit every line of command manually.

 

Step 1: Use the Find/Replace function to add ' to the end of every line.

  • Under the Search Mode group, select Regular expression.
  • Type $ in the Find what textbox.
  • Type ‘ in the Replace with Textbox.
  • Place the cursor on the first line of the file to ensure all lines are affected.
  • Select the Replace All button.

 

1.PNG

Step 2: Use the Find/Replace function to add 'pause 2' to the new line.

  • Under the Search Mode group, select Regular expression.
  • In the Find what text field, type ‘.
  • In the Replace with a text field, type '“\npause 2'.
  • Select Replace All.

 

2.PNG

Step 3: Use the Find/Replace function to add 'sendln' to the beginning of every line.

  • In the Find what text field, type 'diagnose' or ‘get’ or 'fnsysctl'.
  • In the Replace with a text field, type 'sendln ‘diagnose', etc.
  • Select Replace All.

3.PNG

 

4.PNG

 

5.PNG

Step 4: It still needs to edit other parts of the TTL script manually (such as 'Init', 'Main', 'looping',...) but they are usually much shorter than the above main part. More examples can be found at: Technical Tip: TAC debug script with TeraTerm