02-01-2012 03:07 AM - edited 02-01-2012 06:41 PM
What I was wondering is how I can convert an array into a string.
The reason for this is to search for a pattern using a regex into the string (consisted of the array elements).
The array is initialized like this :
var $cmd_syslog = <command> "show log messages | match SNMP_TRAP_LINK_DOWN" ; var $file_content = jcs:execute( $connection, $cmd_syslog ) ; var $lines = jcs:break-lines( $file_content )[ string-length()>0 ] ;
02-02-2012 09:06 AM
Take a look at the str:concat() function, discussed in the SLAX 1.0 Reference Guide on pages 257-258.
BTW, instead of breaking and then recombining the string input minus its newlines perhaps you could just translate() the newlines away so it is just one giant string to start with? Also, pipes are not supported within scripts. It might work but it might not.
02-02-2012 12:14 PM - edited 02-02-2012 02:53 PM
Thank you ccall.
But how you can concat() in a for-each loop (through all the lines of the syslog).
Given that I have a for-each() loop and
in that loop, there is an if() statement, and if that is true(),
I would like to concat the syslog line and to a string.
How can I do that ?