Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


wodrend
2013-08-05T17:54:50Z
I am looking to sens an SMS when a log file gets updated but i only want to send the last line of the log file.

Is there a function similar to the tail command to do this?
Sponsor
Forum information
Support
2013-08-05T19:42:00Z
There is a Variable function that you can use:

{STRING(LastLine|1
2
3)}

So, basically you use the Read file Task and then you can use whatever Task you use to send SMS and include the output Variable from the previous Task with the Last Line Variable like this:

{STRING(LastLine|{TASK(PrevTask|StdOut)})}
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
wodrend
2013-08-05T21:28:09Z
Quote:

{STRING(LastLine|{TASK(PrevTask|StdOut)})}


I get "error in argument"

{TASK(PrevTask|StdOut)} produces the whole output as expected
Support
2013-08-05T21:32:57Z
We just verified and it should work if;

* the Task after read file is the one where you use the Variable
* if the output contains new line characters
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
KJDavie
2013-08-05T22:20:45Z
Hi,

Henrik may have covered this with you offline, but LastLine is a recent (VisualCron 7.0.0) addition.

Pre VisualCron 7 (We are still 6.2.2 on our Production Servers) an easy way to do this was using a couple of lines in a VisualCron powershell task. This example is 3 lines but just change the Select-Object to -Last 1 if that is what you want.

This example also uses a VisualCron Trigger as the filename.

This can be replaced with a more traditional filename "C:\Temp\Somefile.log" if that is how you roll (using variables if you have set your log file name).

--- snip ---
# Get the Last 3 Lines of the File found by the Trigger
$Tail = Get-Content "{TRIGGER(d9a226ae-0ad2-42fb-b518-1efd5af13bf7|LastTrigger|File.Result.FullPath)}" | Select-Object -Last 3

# Write that Variable to Output for use in later VisualCron tasks
Write-Output $Tail
--- snip ---

Hope this helps . . . . see screen print

Regards

Kevin
KJDavie attached the following image(s):
wodrend
2013-08-08T06:44:33Z
Hi Kevin,
Yes, i should of mentioned that i am only on 6.2.2

The powershell task works perfect.

Thanks for your help.

Regards, Rod
Scroll to Top