Automation

last person joined: 8 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  [HELP] Please help me check this script

    Posted 07-23-2013 08:08

    Hi, 

    I am newbie in JunOs Automation. I am now trying practice some script in the ebook but it cant run.

    Could anyone help me correct this script? 

    Here are script

    /* add-route.slax *
    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";
    match / {
    	<op-script-results> {
    		
    		/* Ask for the static route */
    			var $static-route = jcs:get-input("Enter the static route: ");
    		
    		/* Ask for the next-hop */
    			var $next-hop = jcs:get-input("Enter the next-hop: ");
    		
    		/* Create the configuration change */
    			var $configuration = <configuration> {
    				<routing-options> {
    					<static> {
    						<route> {
    							<name> $static-route;
    							<next-hop> $next-hop;
    						}
    					}
    				}
    			}
    
    		/* Open a connection */
    			var $connection = jcs:open();
    		
    		/* Call jcs:load-configuration and provide the connection and configuration change to make. */
    			var $results := { call jcs:load-configuration( $connection, $configuration ); }
    		
    		/* Check for errors – report them if they occurred */
    			if( $results//xnm:error ) {
    				for-each( $results//xnm:error ) {
    				<output> message;
    				}
    			}
    
    		/* If there are no errors then report success */
    			if( jcs:empty( $results//xnm:error ) ) {
    				<output> "Committed without errors.";
    			}
    
    		/* Close the connection */
    			var $close-results = jcs:close($connection);
    	}
    }

     and here are the error message

     

    DatNT@Olive12.1# run op add-route    
    error: ^
    
    error: error: /var/db/scripts/op/add-route.slax: 1 error detected during parsing
    
    error: error reading stylesheet: add-route.slax
    
    error: /var/db/scripts/op/add-route.slax:4: error: /var/db/scripts/op/add-route.slax:3: parse error, unexpected T_BARE, expecting K_VERSION before 'junos': 
    error: ^
    error: error: /var/db/scripts/op/add-route.slax: 1 error detected during parsing
    error: error reading stylesheet: add-route.slax

     

     



  • 2.  RE: [HELP] Please help me check this script
    Best Answer

     
    Posted 07-23-2013 08:21

    Let the script starts with "version" statement. Remove of move current first line.

    /Charlie 



  • 3.  RE: [HELP] Please help me check this script

    Posted 07-23-2013 08:29

    thanks ckim very much. It work great!



  • 4.  RE: [HELP] Please help me check this script

    Posted 07-31-2013 09:12

    You can have leading comments (including both /*XXX*/ and #XXX style), but you have to close the comment.  In the script, you are missing the trailing "/": "/* add-route.slax *".

     

    Thanks,

     Phil