execute command logfile

Post Reply
Joerg Schober
Member
Posts: 30
Joined: Mon Mar 21, 2011 2:30 pm

execute command logfile

Post 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
Joerg Schober
Member
Posts: 30
Joined: Mon Mar 21, 2011 2:30 pm

execute command logfile

Post by Joerg Schober »

thanks for the many replies ;-)



works now.
tz8
Member
Posts: 84
Joined: Mon Aug 13, 2012 12:56 pm

execute command logfile

Post by tz8 »

as we obviously had no clue how to help you would you kindly share your solution?



Cheers,



Thorsten
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

execute command logfile

Post 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
Joerg Schober
Member
Posts: 30
Joined: Mon Mar 21, 2011 2:30 pm

execute command logfile

Post 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
Post Reply