Page 1 of 1

execute command logfile

Posted: Thu May 02, 2013 9:17 am
by Joerg Schober
Hi,

not really scripting related, but i think this is the best-matching forum.



I need a simple logging for Switch and tried it with "execute command". Something like that:



echo "[Job.NameProper]_[Switch.Date:Format=yyyy-MM-dd_hh-mm]" >> ~/switchlog.txt



Is that possible?





BTW, a simple



Command or path: echo

arguments: "hello" >> "~/switchlog.txt"



fails. No error occurs, no file is generated. What's wrong with it?



Kind Regards,

Jörg Schober

execute command logfile

Posted: Tue May 07, 2013 4:12 pm
by Joerg Schober
thanks for the many replies ;-)



works now.

execute command logfile

Posted: Tue May 07, 2013 6:20 pm
by tz8
as we obviously had no clue how to help you would you kindly share your solution?



Cheers,



Thorsten

execute command logfile

Posted: Wed May 08, 2013 4:10 pm
by freddyp
Jörg,



I assume that you would like to have some sort of logging of what files went through the system at what time. It may not exactly fit your needs, but I would like to draw your attention to the following functionality in Switch.



You can set Preferences - Logging - Export messages to XML to "Yes". You will see a few options that are self-explanatory. So you can let Switch regularly export an XML log file, say every hour.



Some other system could then read the XML file and find all the information you need with job names and timestamps.



The difference with what you had in mind is that the information is not immediately available, but if that is not a problem I think this method has more potential than what you are doing, especially in combination "Log job info" element. In "Message text" you can put anything and you use "Scheme" "Direct" with a single-line text with variables. So you can put any piece of information in there and it will end up in the XML.



Freddy

execute command logfile

Posted: Fri May 10, 2013 3:18 pm
by Joerg Schober
tz8 wrote: as we obviously had no clue how to help you would you kindly share your solution?


Hard to believe that none of the other checkers here have a solution ... anyhow - that the solution of a scripting-greenhorn (on a mac):



build a shellscript:

/bin/echo $1 >> $2



setup "execute command":

command or path: path/to/script

arguments:

"[Switch.Date:Format="yyyy-MM-dd hh:mm:ss",TimeZone=System] job:[Job.NameProper]" "/path/to/logfile/switchlog_[Switch.Date:Format="yyyy-MM-dd",TimeZone=System].txt"



So you get daily a new logfile with these content (1 sample line):



2013-05-10 14:52:10 flow:(flow) job:(job)



@Freddy: Thanks for your hint.



regards,

Jörg