====== Tests of CLI Plugin ====== This page provides a set of test cases for the [[plugins:cli|CLI Plugin]] and also serves as an example of its use. ===== Basic Shell Script ===== This shows that * basic ''%%%%'' is perfect for unix command line, * ''%%%%'' can nest, * ''%%%%'' works just fine with MS command box. Wiki text: user@host:~/somedir $ ls # List current directory conf plugin.info.txt README syntax.php lang style.css user@host:~/somedir $ wc info.txt # count words in info.txt 7 20 204 info.txt user@host:~/somedir $ ls \ > -l # Here we ask a long listing (-l) total 40 drwxr-xr-x 2 user user 4096 Dec 27 18:48 conf drwxr-xr-x 4 user user 4096 Dec 22 22:10 lang -rw-rw-rw- 1 user user 204 Dec 22 22:04 plugin.info.txt -rw-rw-rw- 1 user user 1220 Dec 27 18:45 README -rw-r--r-- 1 user user 184 Dec 28 02:13 style.css -rw-rw-rw- 1 user user 18822 Dec 28 06:11 syntax.php user@host:~/somedir $ dosemu (C) Copyright 1995-2006 Pasquale J. Villani and The FreeDOS Project. D: = LINUX\FS/HOME/USER attrib = READ/WRITE E: = LINUX\FS/MEDIA/CDROM CDROM:1 attrib = READ ONLY "Welcome to dosemu 1.4.0.8!" C:\>dir Volume in drive C is mu/drives/c Directory of C:\ TMP 12-28-17 6:29a CONFIG SYS 346 06-22-15 1:17a AUTOEXEC BAT 556 06-22-15 1:17a 2 file(s) 902 bytes 1 dir(s) 2,147,450,880 bytes free C:\>echo pouet pouet C:\>rem This is a remark and does nothing C:\>echo But this rem is not a remark. But this rem is not a remark. C:\>exit user@host:~/somedir $ echo Ah. Back to normal again Ah. Back to normal again user@host:~/somedir $ Rendered result : user@host:~/somedir $ ls # List current directory conf plugin.info.txt README syntax.php lang style.css user@host:~/somedir $ wc info.txt # count words in info.txt 7 20 204 info.txt user@host:~/somedir $ ls \ > -l # Here we ask a long listing (-l) total 40 drwxr-xr-x 2 user user 4096 Dec 27 18:48 conf drwxr-xr-x 4 user user 4096 Dec 22 22:10 lang -rw-rw-rw- 1 user user 204 Dec 22 22:04 plugin.info.txt -rw-rw-rw- 1 user user 1220 Dec 27 18:45 README -rw-r--r-- 1 user user 184 Dec 28 02:13 style.css -rw-rw-rw- 1 user user 18822 Dec 28 06:11 syntax.php user@host:~/somedir $ dosemu (C) Copyright 1995-2006 Pasquale J. Villani and The FreeDOS Project. D: = LINUX\FS/HOME/USER attrib = READ/WRITE E: = LINUX\FS/MEDIA/CDROM CDROM:1 attrib = READ ONLY "Welcome to dosemu 1.4.0.8!" C:\>dir Volume in drive C is mu/drives/c Directory of C:\ TMP 12-28-17 6:29a CONFIG SYS 346 06-22-15 1:17a AUTOEXEC BAT 556 06-22-15 1:17a 2 file(s) 902 bytes 1 dir(s) 2,147,450,880 bytes free C:\>echo pouet pouet C:\>rem This is a remark and does nothing C:\>echo But this rem is not a remark. But this rem is not a remark. C:\>exit user@host:~/somedir $ echo Ah. Back to normal again Ah. Back to normal again user@host:~/somedir $ ===== Ruby irb ===== Simple minded implementation will not work for results as end of prompt is same as results marker! But named type ''irb'' can handle ruby quite well. irb(main):001:0> 2+2 => 4 irb(main):002:0> irb(main):003:0> 2 + # This is a comment irb(main):004:0* 40 => 42 irb(main):005:0> irb(main):001:0> 2+2 => 4 irb(main):002:0> irb(main):001:0> 2 + # This is a comment irb(main):002:0* 40 => 42 irb(main):003:0> ===== Python ===== ActivePython 2.5.1.1 (ActiveState Software Inc.) based on Python 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 2+2 4 >>> ActivePython 2.5.1.1 (ActiveState Software Inc.) based on Python 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 2+2 4 >>> ===== Corner Cases ===== * The following codes don't display right # rpm -ivh darcs-1.0.9-3.fc6.i386.rpm Preparing... ########################################### [100%] 1:darcs ########################################### [100%] # rpm -ivh darcs-1.0.9-3.fc6.i386.rpm Preparing... ########################################### [100%] 1:darcs ########################################### [100%] Not sure to do about this as download progress marker uses same character as prompt! * CLI shouldn't silently eat intentional blank lines: End of original demo ----------------------------------------------- ===== Other examples ===== ==== blank lines ==== intentional blank lines are preserved user@host:~/somedir $ ls # List current directory conf lang README screen,gif ui info.txt manager.dat renderer.php syntax.php user@host:~/somedir $ # Yes the 2 blank lines above are intentional. user@host:~/somedir $ ls # List current directory conf lang README screen,gif ui info.txt manager.dat renderer.php syntax.php user@host:~/somedir $ # Yes the 2 blank lines above are intentional. ==== nesting ==== There are 2 %%%% nested here : user@host:~/somedir $ ls # List current directory | tee /tmp/foo < /dev/null conf lang README screen,gif ui info.txt manager.dat renderer.ph syntax.php z $ \ >>> # see next line >>> :<>> This is not a continuation line. user@host:~/somedir $ dosemu # two blank lines above. c:\> dir directory of C:\. . 16-12-2017 9:03 .. 16-12-2017 8:57 caramba txt 1023 16-12-2017 14:23 1 File(s) 1023 Bytes. 2 Dir(s) 262,111,744 Bytes free. C:\docs> exit user@host:~/somedir $ echo 'pouet & repouet' pouet & repouet user@host:~/somedir $ user@host:~/somedir $ ls # List current directory | tee /tmp/foo < /dev/null conf lang README screen,gif ui info.txt manager.dat renderer.ph syntax.php z $ \ >>> # see next line >>> :<>> This is not a continuation line. user@host:~/somedir $ dosemu # two blank lines above. c:\> dir directory of C:\. . 16-12-2017 9:03 .. 16-12-2017 8:57 caramba txt 1023 16-12-2017 14:23 1 File(s) 1023 Bytes. 2 Dir(s) 262,111,744 Bytes free. C:\docs> exit user@host:~/somedir $ echo 'pouet & repouet' pouet & repouet user@host:~/somedir $ --------------------- This could also have been done in one %%%% provided you are a master at regexp user@host:~/somedir $ ls # List current directory | tee /tmp/foo < /dev/null conf lang README screen,gif ui info.txt manager.dat renderer.ph syntax.php z $ \ >>> # see next line >>> :<>> This is not a continuation line. user@host:~/somedir $ dosemu # two blank lines above. c:\> cd docs c:\docs> dir directory of C:\docs. . 16-12-2017 9:03 .. 16-12-2017 8:57 caramba txt 1023 16-12-2017 14:23 1 File(s) 1023 Bytes. 2 Dir(s) 262,111,744 Bytes free. C:\docs> exit user@host:~/somedir $ echo 'pouet & repouet' pouet & repouet user@host:~/somedir $ user@host:~/somedir $ ls # List current directory | tee /tmp/foo < /dev/null conf lang README screen,gif ui info.txt manager.dat renderer.ph syntax.php z $ \ >>> # see next line >>> :<>> This is not a continuation line. user@host:~/somedir $ dosemu # two blank lines above. c:\> cd docs c:\docs> dir directory of C:\docs. . 16-12-2017 9:03 .. 16-12-2017 8:57 caramba txt 1023 16-12-2017 14:23 1 File(s) 1023 Bytes. 2 Dir(s) 262,111,744 Bytes free. C:\docs> exit user@host:~/somedir $ echo 'pouet & repouet' pouet & repouet user@host:~/somedir $ ===== prompt without space ===== Some command line do not use a space after their prompt. For example, cmd.exe or the command line interface of switch. In this case, use the preset nospace type user@myserver:~$ minicom Welcome to minicom 2.7 OPTIONS: I18n Compiled on Apr 22 2017, 09:14:19. Port /dev/ttyS1 Press CTRL-A Z for help on special keys console>enable Password:******************** console#config console(config)#crypto key generate dsa console(config)#crypto key generate rsa console(config)#ip ssh server console(config)#aaa authentication login networkList line console(config)#aaa authentication enable networkList line console(config)#line ssh console(config-line)#login authentication networkList console(config-line)#enable authentication networkList console(config-line)#password Sup3rPassW0RD console(config-line)#exit console(config)#exit console#copy running-config startup-config user@myserver:~$ minicom Welcome to minicom 2.7 OPTIONS: I18n Compiled on Apr 22 2017, 09:14:19. Port /dev/ttyS1 Press CTRL-A Z for help on special keys console>enable Password:******************** console#config console(config)#crypto key generate dsa console(config)#crypto key generate rsa console(config)#ip ssh server console(config)#aaa authentication login networkList line console(config)#aaa authentication enable networkList line console(config)#line ssh console(config-line)#login authentication networkList console(config-line)#enable authentication networkList console(config-line)#password Sup3rPassW0RD console(config-line)#exit console(config)#exit console#copy running-config startup-config