FSM-Basic

 view release on metacpan or  search on metacpan

examples/FSM_fake_bash.json  view on Meta::CPAN

				"cmd": "ping  ",
				"matching": "ping_target",
				"output": "Target IP address: "
			},
			"end": {
				"matching": "in_enable"
			}
		},
		"not_matching_info": "% not a protocol",
		"output": "ping [IP]:  ***"
	},
	"ping_target": {
		"expect": {
			"(?^:.*)": {
				"cmd": "$in ",
				"matching": "ping_count",
				"output": "Repeat count [5]:"
			},
			"end": {
				"matching": "in_enable"
			}
		},
		"not_matching_info": "% not an ip",
		"output": "Target IP address: "
	},
	"ping_timeout": {
		"expect": {
			"(?^:\\d+)": {
				"cmd": "-W $in",
				"cmd_exec": 1,
				"matching": "ping_timeout",
				"output": "__ENPROMPT__"
			},
			"end": {
				"matching": "in_enable"
			}
		},
		"not_matching_info": "% not a number",
		"output": "Repeat count [5]: "
	},
	"shutdown": {
		"final": 2
	},
	"prompt": {
		"expect": {
			"(?^:(?^:^en((a)|(ab)|(abl)|(able))?$))": {
				"final": 0,
				"matching": "prompt_enable"
			},
                        "test": {
                            "cat": "test.txt"
                        },
                        "test1": {
                            "catRAND": "test.txt test.txt test1.txt"
                        },
                        "test2": {
                            "catSEQ": "test.txt test1.txt test2.txt",
                            "catSEQ_idxf": "test_state"
                        },
			"mem": {
				"do": "my ( $tot,$avail) = (split /\n/ ,do { local( @ARGV, $/ ) = \"/proc/meminfo\" ; <> })[0,2];$tot =~ s/\\D*//g; $avail =~ s/\\D*//g; sprintf \"%0.2f%%\\n\",(100*($tot-$avail)/$tot);"
			},
			"mem1": {
				"exec": "/usr/bin/perl -E 'my ( $tot,$avail) = (split /\\n/ ,do { local( @ARGV, $/ ) = \"/proc/meminfo\" ; <> })[0,2];$tot =~ s/\\D*//g; $avail =~ s/\\D*//g; printf \"%0.2f%%\\n\",(100*($tot-$avail)/$tot);'"
			},
			"df": {
				"exec": "/bin/df"
			},
			"exit": {
				"final": 0,
				"matching": "close"
			},
			"h(elp)?|\\?": {
				"output": "enable\nexit\nmeminfo\ndf\n__PROMPT__"
			},
			"meminfo": {
				"do": "do { local( @ARGV, $/ ) = \"/proc/meminfo\" ; <> }"
			}
		},
		"not_matching": "prompt",
		"not_matching_info": "% Unknown command or computer name, or unable to find computer address",
		"output": "__PROMPT__"
	},
	"prompt_enable": {
		"expect": {
			"default": {
				"final": 0,
				"matching": "in_enable",
				"output": "__ENPROMPT__"
			}
		},
		"not_matching": "prompt_enable",
		"not_matching0": "prompt",
		"not_matching_info_last": "% Bad secrets\n",
		"output": "Password: ",
		"repeat": 2
	}
}



( run in 0.887 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )