Hi
I have a SLAX op script, which is taking user input IP as an argument. I am trying to add the follwoing template to it:
If argument was not specified, request one. If IP format is incorrect terminate script execution. I have done the below, the first works ok. I am trying to verify IP by using jcs: parse-ip function, but it does not interrupt the script.
I also struggle to convert the code below to a template.
version 1.0;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";
/* Request IP input */
param $ip ;
var $arguments = {
<argument> {
<name> "ip" ;
<description> "Enter IP <ip-address> " ;
}
}
match / {
<op-script-results> {
var $ip_address = { if(jcs:empty($ip)) {
expr jcs:get-input("Enter IP address: ") ;
}
else {
expr $ip;
}
}
var $test_ip = jcs: parse-ip($ip_address) ;
if ($test_ip/xnm:error) {
<xsl:message terminate="yes"> "Incorrect IP";
}
/*Script....*/
<output> "Script complete" ;
}
}