final edit fixes

This commit is contained in:
Wifinigel 2023-02-19 13:53:15 +00:00
parent b10b99bd87
commit f3beb2ed9b
41 changed files with 164 additions and 150 deletions

View file

@ -1,4 +1,4 @@
:global Filename "ch10-04-bad-script.rsc"
:local Filename "ch10-04-bad-script.rsc"
# A simple script to perform a series of tests on a
# list of web sites.
@ -17,9 +17,10 @@
:global LogMessageFunc;
# check arg type str of correct length passed
if (([:typeof $WebSiteName]!="str") or ([:len value=$WebSiteName] < 6)) do={
$LogMessageFunc ("DnsResolveFunc: arg value $WebSiteName not a valid \
string!");
if (([:typeof $WebSiteName]!="str") or \
([:len value=$WebSiteName] < 6)) do={
$LogMessageFunc ("DnsResolveFunc: arg value $WebSiteName not \
a valid string!");
}
return [/resolve $WebSiteName];
@ -32,8 +33,8 @@
# check arg type ip is passed
if ([:typeof $IpAddress] != "ip") do={
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not an IP \
address!");
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not \
an IP address!");
}
return [/ping $IpAddress count=3];
@ -45,13 +46,14 @@
:global LogMessageFunc;
# check arg type str of correct length passed
if (([:typeof $SiteName] != "str") or ([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a valid \
string!");
if (([:typeof $SiteName] != "str") or \
([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a \
valid string!");
}
return [/tool fetch url=("https://$SiteName") mode=https http-method=get \
as-value keep-result=no];
return [/tool fetch url=("https://$SiteName") mode=https \
http-method=get as-value keep-result=no];
}
##########
@ -83,7 +85,6 @@
}
# cleanup global namespace
:set Filename;
:set LogMessageFunc;
:set DnsResolveFunc;
:set PingIpAddressFunc;

View file

@ -4,7 +4,7 @@
:do {
:local SiteIpAddress [/resolve $SiteName];
:put "Site IP for $SiteName is $SiteIpAddress";
} on-error {
} on-error={
:put "Name lookup failed for $SiteName"
}
}

View file

@ -1,4 +1,4 @@
:global Filename "ch10-07-bad-script.rsc"
:local Filename "ch10-07-bad-script.rsc"
# A script to perform a series of tests on a
# list of web sites.
@ -19,8 +19,8 @@
# check arg type str of correct length passed
:if (([:typeof $WebSiteName] != "str") or \
([:len value=$WebSiteName] < 6)) do={
$LogMessageFunc ("DnsResolveFunc: arg value $WebSiteName not a valid \
string!");
$LogMessageFunc ("DnsResolveFunc: arg value $WebSiteName not \
a valid string!");
:return "*** test failed ***";
}
@ -29,8 +29,8 @@
:do {
return [/resolve $WebSiteName];
} on-error={
$LogMessageFunc ("DnsResolveFunc: name resolution failed for site: \
$WebSiteName!");
$LogMessageFunc ("DnsResolveFunc: name resolution failed for \
site: $WebSiteName!");
:return "*** test failed ***";
}
}
@ -42,16 +42,17 @@
# check arg type ip is passed
:if ([:typeof $IpAddress] != "ip") do={
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not an \
IP address!");
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not \
an IP address!");
:return "*** test failed ***";
}
# try a ping
:do {
return [/ping $IpAddress count=3];
} on-error {
$LogMessageFunc ("PingIpAddressFunc: ping test failed: $IpAddress !");
} on-error={
$LogMessageFunc ("PingIpAddressFunc: ping test failed: \
$IpAddress !");
:return "*** test failed ***";
}
}
@ -62,9 +63,10 @@
:global LogMessageFunc;
# check arg type str of correct length passed
:if (([:typeof $SiteName] != "str") or ([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a valid \
string!");
:if (([:typeof $SiteName] != "str") or \
([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a \
valid string!");
:return "*** test failed ***";
}
@ -72,7 +74,7 @@
:do {
:return [/tool fetch url=("https://$SiteName") mode=https \
http-method=get as-value keep-result=no];
} on-error {
} on-error={
$LogMessageFunc ("GetWebPageFunc: unable to retrieve site: \
$SiteName !");
:return { "duration"="*** test failed ***" }
@ -108,7 +110,6 @@
}
# cleanup global namespace
:set Filename;
:set LogMessageFunc;
:set DnsResolveFunc;
:set PingIpAddressFunc;

View file

@ -1,4 +1,4 @@
:global Filename "ch10-08-bad-script.rsc"
:local Filename "ch10-08-bad-script.rsc"
# A script to perform a series of tests on a
# list of web sites.
@ -35,8 +35,8 @@
:if (([:typeof $WebSiteName] != "str") or \
([:len value=$WebSiteName] < 6)) do={
:local ErrorMsg "DnsResolveFunc: arg value $WebSiteName not a valid \
string!";
:local ErrorMsg "DnsResolveFunc: arg value $WebSiteName \
not a valid string!";
$LogMessageFunc $ErrorMsg;
$DebugFunc $ErrorMsg;
:return "*** test failed ***";
@ -51,8 +51,8 @@
:return $SiteIpAddr;
} on-error={
$DebugFunc "DNS lookup failed!";
$LogMessageFunc ("DnsResolveFunc: name resolution failed for site: \
$WebSiteName!");
$LogMessageFunc ("DnsResolveFunc: name resolution failed for \
site: $WebSiteName!");
:return "*** test failed ***";
}
}
@ -64,16 +64,16 @@
# check arg type ip is passed
:if ([:typeof $IpAddress] != "ip") do={
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not an IP \
address!");
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not \
an IP address!");
:return "*** test failed ***";
}
:do {
return [/ping $IpAddress count=3];
} on-error {
$LogMessageFunc ("PingIpAddressFunc: ping test to IP address failed: \
$IpAddress !");
$LogMessageFunc ("PingIpAddressFunc: ping test to IP address \
failed: $IpAddress !");
:return "*** test failed ***";
}
}
@ -84,17 +84,19 @@
:global LogMessageFunc;
# check arg type str of correct length passed
if (([:typeof $SiteName] != "str") or ([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a valid \
string!");
if (([:typeof $SiteName] != "str") or \
([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a \
valid string!");
:return { "duration"="*** test failed ***" };
}
do {
return [/tool fetch url=("https://$SiteName") mode=https http-method=get \
as-value keep-result=no];
return [/tool fetch url=("https://$SiteName") mode=https \
http-method=get as-value keep-result=no];
} on-error {
$LogMessageFunc ("GetWebPageFunc: unable to retrieve site: $SiteName !");
$LogMessageFunc ("GetWebPageFunc: unable to retrieve site: \
$SiteName !");
return { "duration"="*** test failed ***" };
}
}
@ -128,7 +130,6 @@
}
# cleanup global namespace
:set Filename;
:set LogMessageFunc;
:set DnsResolveFunc;
:set PingIpAddressFunc;

View file

@ -1,6 +1,6 @@
# ch10-10-add-remove-vlans.rsc
# a script to add and remove 50 VLANs to/from
# a script to add and remove 50 VLANs to/fromon-error={
# a Mikrotik router interface
:for VlanId from 200 to 249 do={

View file

@ -1,6 +1,6 @@
# ch5-05-indentation.rsc
# Create an if-else statement with no additional indentation
# Create an if-else statement with indentation
:local DayOfWeek "Monday";
if ($DayOfWeek = "Monday") do={

View file

@ -7,13 +7,13 @@
:put ("Variable contents: $SmallNumber");
# Assign some data to the variable
:set SmallNumber 2
:set SmallNumber 2;
# Print its value again
:put ("Variable contents: $SmallNumber");
# Let's change the variable value
:set SmallNumber 3
:set SmallNumber 3;
# Print its value again
:put ("Variable contents: $SmallNumber");

View file

@ -15,7 +15,8 @@ if ( [:typeof $WanInterfaces] = "nothing") do={
# Is the variable an array data type?
if ( [:typeof $WanInterfaces] != "array") do={
:error "The WanInterfaces global variable is not an array data type. Exiting."
:error "The WanInterfaces global variable is not an array data \
type. Exiting."
}
# Let's step through the interfaces in the array

View file

@ -24,6 +24,6 @@ if ( $WanPingCount = 0) do={
}
if ( ($WanPingCount < $PingCount) and ($WanPingCount > 0) ) do={
:log warning "The Internet connection may be degraded. (Ping result: \
$WanPingCount/$PingCount)";
:log warning "The Internet connection may be degraded. (Ping \
result: $WanPingCount/$PingCount)";
}

View file

@ -5,7 +5,7 @@
:put "The current time is : $CurrentTime";
# declare the time of day variable
:local TimeOfDay
:local TimeOfDay;
# Check if it's very early
:if (($CurrentTime >= 00:00) and ($CurrentTime < 06:00)) do={

View file

@ -5,7 +5,7 @@
:put "The current time is : $CurrentTime";
# declare the time of day variable
:local TimeOfDay
:local TimeOfDay;
# Check if it's before noon
:if ($CurrentTime < 12:00) do={
@ -13,7 +13,8 @@
# it's before noon, let's see what time of the morning
# it is using a nested if-else statement
if ($CurrentTime < 06:00) do={
:set TimeOfDay "It's very early in the morning...shouldn't you be in bed?";
:set TimeOfDay "It's very early in the morning...shouldn't \
you be in bed?";
} else={
# it must be between 06:01 and 11:59 to reach here
:set TimeOfDay "Good morning!";

View file

@ -3,12 +3,12 @@
# define WAN interface name
:local WanInterfaceName "ether1-WAN";
# find the interface index
:local InterfaceIndex [/interface ethernet find name=$WanInterfaceName];
# find the interface ID
:local InterfaceId [/interface ethernet find name=$WanInterfaceName];
:local UpDown;
if ([:interface ethernet get $InterfaceIndex]->"running") do={
if ([:interface ethernet get $InterfaceId]->"running") do={
:set UpDown "up";
} else={
:set UpDown "down";

View file

@ -4,10 +4,10 @@
:local WanInterfaceName "ether1-WAN";
# find the interface index
:local InterfaceIndex [/interface ethernet find name=$WanInterfaceName];
:local InterfaceId [/interface ethernet find name=$WanInterfaceName];
:local UpDown "down";
if ([:interface ethernet get $InterfaceIndex]->"running") do={
if ([:interface ethernet get $InterfaceId]->"running") do={
:set UpDown "up"
}

View file

@ -4,7 +4,7 @@
# the 12 times table
:for LoopCount from=1 to=5 do={
:put ("Current loop counter is: $LoopCount");
:put "Current loop counter is: $LoopCount";
:put ("12 x $LoopCount is: " . (12 * $LoopCount));
}

View file

@ -12,9 +12,8 @@
:local PingResult [/ping $Site count=3 ];
:if ($PingResult > 0) do {
:put ("\nWeb site $Site reached OK\n");
:put "\nWeb site $Site reached OK\n";
} else={
:put ("\nNo response from web site: $Site\n");
:put "\nNo response from web site: $Site\n";
}
}

View file

@ -8,8 +8,8 @@
:for VlanId from=100 to=150 step=10 do={
:put ("Creating VLAN $VlanId on interface $InterfaceName");
:local VlanName ("vlan" . $VlanId);
/interface vlan add name=$VlanName vlan-id=$VlanId interface=$InterfaceName;
/interface vlan add name=$VlanName vlan-id=$VlanId \
interface=$InterfaceName;
}

View file

@ -28,12 +28,14 @@
}
# data type checks passed, print the interface data
:put "$InterfaceName: IP address = $InterfaceIp, speed = $InterfaceSpeed";
:put "$InterfaceName: IP address = $InterfaceIp, speed = \
$InterfaceSpeed";
}
# --- end of function ---
# Let's call the function with some sample values in an array
:local Args { ifname="WAN1"; ifspeed="100Mbps"; ifip="192.168.99.1/24" };
:local Args { ifname="WAN1"; ifspeed="100Mbps";
ifip="192.168.99.1/24" };
$PrintInterfaceAttrsFunc $Args;
# Let's call the function with some other values in an array

View file

@ -16,7 +16,7 @@
# function to remove last char from a string
#
# e.g. :local ChoppedVar [$chopStrFunc "string with extra char,"]
# e.g. :local ChoppedVar [$ChopStrFunc "string with extra char,"]
#
:global ChopStrFunc do={
:return [ :pick $1 0 ( [ :len $1 ] -1 ) ];

View file

@ -1,6 +1,7 @@
# filename: ch9-07-use-str-module.rsc
# import the functions we need and declare the function names we wish to use
# import the functions we need and declare the function
# names we wish to use
/import "ch9-06-str-funcs-mod.rsc"
:global RemoveSpaceFunc;
:global ChopStrFunc;

View file

@ -1,4 +1,4 @@
:global Filename "ch10-04-bad-script.rsc"
:local Filename "ch10-04-bad-script.rsc"
# A simple script to perform a series of tests on a
# list of web sites.
@ -17,9 +17,10 @@
:global LogMessageFunc;
# check arg type str of correct length passed
if (([:typeof $WebSiteName]!="str") or ([:len value=$WebSiteName] < 6)) do={
$LogMessageFunc ("DnsResolveFunc: arg value $WebSiteName not a valid \
string!");
if (([:typeof $WebSiteName]!="str") or \
([:len value=$WebSiteName] < 6)) do={
$LogMessageFunc ("DnsResolveFunc: arg value $WebSiteName not \
a valid string!");
}
return [/resolve $WebSiteName];
@ -32,8 +33,8 @@
# check arg type ip is passed
if ([:typeof $IpAddress] != "ip") do={
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not an IP \
address!");
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not \
an IP address!");
}
return [/ping $IpAddress count=3];
@ -45,13 +46,14 @@
:global LogMessageFunc;
# check arg type str of correct length passed
if (([:typeof $SiteName] != "str") or ([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a valid \
string!");
if (([:typeof $SiteName] != "str") or \
([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a \
valid string!");
}
return [/tool fetch url=("https://$SiteName") mode=https http-method=get \
as-value keep-result=no];
return [/tool fetch url=("https://$SiteName") mode=https \
http-method=get as-value keep-result=no];
}
##########
@ -83,7 +85,6 @@
}
# cleanup global namespace
:set Filename;
:set LogMessageFunc;
:set DnsResolveFunc;
:set PingIpAddressFunc;

View file

@ -4,7 +4,7 @@
:do {
:local SiteIpAddress [/resolve $SiteName];
:put "Site IP for $SiteName is $SiteIpAddress";
} on-error {
} on-error={
:put "Name lookup failed for $SiteName"
}
}

View file

@ -1,4 +1,4 @@
:global Filename "ch10-07-bad-script.rsc"
:local Filename "ch10-07-bad-script.rsc"
# A script to perform a series of tests on a
# list of web sites.
@ -19,8 +19,8 @@
# check arg type str of correct length passed
:if (([:typeof $WebSiteName] != "str") or \
([:len value=$WebSiteName] < 6)) do={
$LogMessageFunc ("DnsResolveFunc: arg value $WebSiteName not a valid \
string!");
$LogMessageFunc ("DnsResolveFunc: arg value $WebSiteName not \
a valid string!");
:return "*** test failed ***";
}
@ -29,8 +29,8 @@
:do {
return [/resolve $WebSiteName];
} on-error={
$LogMessageFunc ("DnsResolveFunc: name resolution failed for site: \
$WebSiteName!");
$LogMessageFunc ("DnsResolveFunc: name resolution failed for \
site: $WebSiteName!");
:return "*** test failed ***";
}
}
@ -42,16 +42,17 @@
# check arg type ip is passed
:if ([:typeof $IpAddress] != "ip") do={
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not an \
IP address!");
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not \
an IP address!");
:return "*** test failed ***";
}
# try a ping
:do {
return [/ping $IpAddress count=3];
} on-error {
$LogMessageFunc ("PingIpAddressFunc: ping test failed: $IpAddress !");
} on-error={
$LogMessageFunc ("PingIpAddressFunc: ping test failed: \
$IpAddress !");
:return "*** test failed ***";
}
}
@ -62,9 +63,10 @@
:global LogMessageFunc;
# check arg type str of correct length passed
:if (([:typeof $SiteName] != "str") or ([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a valid \
string!");
:if (([:typeof $SiteName] != "str") or \
([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a \
valid string!");
:return "*** test failed ***";
}
@ -72,7 +74,7 @@
:do {
:return [/tool fetch url=("https://$SiteName") mode=https \
http-method=get as-value keep-result=no];
} on-error {
} on-error={
$LogMessageFunc ("GetWebPageFunc: unable to retrieve site: \
$SiteName !");
:return { "duration"="*** test failed ***" }
@ -108,7 +110,6 @@
}
# cleanup global namespace
:set Filename;
:set LogMessageFunc;
:set DnsResolveFunc;
:set PingIpAddressFunc;

View file

@ -1,4 +1,4 @@
:global Filename "ch10-08-bad-script.rsc"
:local Filename "ch10-08-bad-script.rsc"
# A script to perform a series of tests on a
# list of web sites.
@ -35,8 +35,8 @@
:if (([:typeof $WebSiteName] != "str") or \
([:len value=$WebSiteName] < 6)) do={
:local ErrorMsg "DnsResolveFunc: arg value $WebSiteName not a valid \
string!";
:local ErrorMsg "DnsResolveFunc: arg value $WebSiteName \
not a valid string!";
$LogMessageFunc $ErrorMsg;
$DebugFunc $ErrorMsg;
:return "*** test failed ***";
@ -51,8 +51,8 @@
:return $SiteIpAddr;
} on-error={
$DebugFunc "DNS lookup failed!";
$LogMessageFunc ("DnsResolveFunc: name resolution failed for site: \
$WebSiteName!");
$LogMessageFunc ("DnsResolveFunc: name resolution failed for \
site: $WebSiteName!");
:return "*** test failed ***";
}
}
@ -64,16 +64,16 @@
# check arg type ip is passed
:if ([:typeof $IpAddress] != "ip") do={
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not an IP \
address!");
$LogMessageFunc ("PingIpAddressFunc: arg value $IpAddress not \
an IP address!");
:return "*** test failed ***";
}
:do {
return [/ping $IpAddress count=3];
} on-error {
$LogMessageFunc ("PingIpAddressFunc: ping test to IP address failed: \
$IpAddress !");
$LogMessageFunc ("PingIpAddressFunc: ping test to IP address \
failed: $IpAddress !");
:return "*** test failed ***";
}
}
@ -84,17 +84,19 @@
:global LogMessageFunc;
# check arg type str of correct length passed
if (([:typeof $SiteName] != "str") or ([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a valid \
string!");
if (([:typeof $SiteName] != "str") or \
([:len value=$SiteName] < 6)) do={
$LogMessageFunc ("GetWebPageFunc: arg value $SiteName not a \
valid string!");
:return { "duration"="*** test failed ***" };
}
do {
return [/tool fetch url=("https://$SiteName") mode=https http-method=get \
as-value keep-result=no];
return [/tool fetch url=("https://$SiteName") mode=https \
http-method=get as-value keep-result=no];
} on-error {
$LogMessageFunc ("GetWebPageFunc: unable to retrieve site: $SiteName !");
$LogMessageFunc ("GetWebPageFunc: unable to retrieve site: \
$SiteName !");
return { "duration"="*** test failed ***" };
}
}
@ -128,7 +130,6 @@
}
# cleanup global namespace
:set Filename;
:set LogMessageFunc;
:set DnsResolveFunc;
:set PingIpAddressFunc;

View file

@ -7,13 +7,13 @@
:put ("Variable contents: $SmallNumber");
# Assign some data to the variable
:set SmallNumber 2
:set SmallNumber 2;
# Print its value again
:put ("Variable contents: $SmallNumber");
# Let's change the variable value
:set SmallNumber 3
:set SmallNumber 3;
# Print its value again
:put ("Variable contents: $SmallNumber");

View file

@ -15,7 +15,8 @@ if ( [:typeof $WanInterfaces] = "nothing") do={
# Is the variable an array data type?
if ( [:typeof $WanInterfaces] != "array") do={
:error "The WanInterfaces global variable is not an array data type. Exiting."
:error "The WanInterfaces global variable is not an array data \
type. Exiting."
}
# Let's step through the interfaces in the array

View file

@ -24,6 +24,6 @@ if ( $WanPingCount = 0) do={
}
if ( ($WanPingCount < $PingCount) and ($WanPingCount > 0) ) do={
:log warning "The Internet connection may be degraded. (Ping result: \
$WanPingCount/$PingCount)";
:log warning "The Internet connection may be degraded. (Ping \
result: $WanPingCount/$PingCount)";
}

View file

@ -5,7 +5,7 @@
:put "The current time is : $CurrentTime";
# declare the time of day variable
:local TimeOfDay
:local TimeOfDay;
# Check if it's very early
:if (($CurrentTime >= 00:00) and ($CurrentTime < 06:00)) do={

View file

@ -5,7 +5,7 @@
:put "The current time is : $CurrentTime";
# declare the time of day variable
:local TimeOfDay
:local TimeOfDay;
# Check if it's before noon
:if ($CurrentTime < 12:00) do={
@ -13,7 +13,8 @@
# it's before noon, let's see what time of the morning
# it is using a nested if-else statement
if ($CurrentTime < 06:00) do={
:set TimeOfDay "It's very early in the morning...shouldn't you be in bed?";
:set TimeOfDay "It's very early in the morning...shouldn't \
you be in bed?";
} else={
# it must be between 06:01 and 11:59 to reach here
:set TimeOfDay "Good morning!";

View file

@ -3,12 +3,12 @@
# define WAN interface name
:local WanInterfaceName "ether1-WAN";
# find the interface index
:local InterfaceIndex [/interface/ethernet find name=$WanInterfaceName];
# find the interface ID
:local InterfaceId [/interface/ethernet find name=$WanInterfaceName];
:local UpDown;
if ([:interface ethernet get $InterfaceIndex]->"running") do={
if ([:interface ethernet get $InterfaceId]->"running") do={
:set UpDown "up";
} else={
:set UpDown "down";

View file

@ -4,10 +4,10 @@
:local WanInterfaceName "ether1-WAN";
# find the interface index
:local InterfaceIndex [/interface/ethernet find name=$WanInterfaceName];
:local InterfaceId [/interface/ethernet find name=$WanInterfaceName];
:local UpDown "down";
if ([:interface/ethernet get $InterfaceIndex]->"running") do={
if ([:interface/ethernet get $InterfaceId]->"running") do={
:set UpDown "up"
}

View file

@ -4,7 +4,7 @@
# the 12 times table
:for LoopCount from=1 to=5 do={
:put ("Current loop counter is: $LoopCount");
:put "Current loop counter is: $LoopCount";
:put ("12 x $LoopCount is: " . (12 * $LoopCount));
}

View file

@ -12,9 +12,8 @@
:local PingResult [/ping $Site count=3 ];
:if ($PingResult > 0) do {
:put ("\nWeb site $Site reached OK\n");
:put "\nWeb site $Site reached OK\n";
} else={
:put ("\nNo response from web site: $Site\n");
:put "\nNo response from web site: $Site\n";
}
}

View file

@ -8,8 +8,8 @@
:for VlanId from=100 to=150 step=10 do={
:put ("Creating VLAN $VlanId on interface $InterfaceName");
:local VlanName ("vlan" . $VlanId);
/interface vlan add name=$VlanName vlan-id=$VlanId interface=$InterfaceName;
/interface vlan add name=$VlanName vlan-id=$VlanId \
interface=$InterfaceName;
}

View file

@ -28,7 +28,8 @@
}
# data type checks passed, print the interface data
:put "$InterfaceName: IP address = $InterfaceIp, speed = $InterfaceSpeed";
:put "$InterfaceName: IP address = $InterfaceIp, speed = \
$InterfaceSpeed";
}
# --- end of function ---
@ -37,7 +38,8 @@
$PrintInterfaceAttrsFunc $Args;
# Let's call the function with some other values in an array
:set Args { ifname="ether2-LAN"; ifspeed="1000Mbps"; ifip="172.16.1.254/24" };
:set Args { ifname="ether2-LAN"; ifspeed="1000Mbps";
ifip="172.16.1.254/24" };
$PrintInterfaceAttrsFunc $Args;
# Cleanup global namespace

View file

@ -16,7 +16,7 @@
# function to remove last char from a string
#
# e.g. :local ChoppedVar [$chopStrFunc "string with extra char,"]
# e.g. :local ChoppedVar [$ChopStrFunc "string with extra char,"]
#
:global ChopStrFunc do={
:return [ :pick $1 0 ( [ :len $1 ] -1 ) ];

View file

@ -1,6 +1,7 @@
# filename: ch9-07-use-str-module.rsc
# import the functions we need and declare the function names we wish to use
# import the functions we need and declare the function
# names we wish to use
/import "ch9-06-str-funcs-mod.rsc"
:global RemoveSpaceFunc;
:global ChopStrFunc;