Community forum

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


fritfald
2019-01-17T13:00:06Z
I'm running a ssh task from Visualcron on a linuxserver, and the script I'm running is set to return "exit $antal"
and $antal can be 0 og 1.

But in the task line of Visualcron it doesn't get the exitcode, it show 0 all the time, even if I run the script by hand with putty, and I get a 1.

i copy/pasted the last lines of the script.

antal=`(
sql -s $db << SLUT
select count(*) from bstlhoved
where jobopl_job = '$job'
and koer_dato = '$prdato'
and slut_tid = ''
and godkendt_jn = 'j'
;commit;
\g\q
SLUT
) | grep -E '\| *[0-9][0-9]*\|' | cut -d'|' -f 2`

log "job/task: $job database: $db $brp prdato: $prdato antal: $antal"

echo $antal

exit $antal


How do I get hold of some returncode/exit code controlled by a script?
Sponsor
Forum information
Support
2019-01-18T10:21:07Z
The exit code in SSH execution says if it was a success or not - at least at command level.

I would write the result to console instead and then you can use that value in upcoming Task through Variable {TASK(PrevTask|StdOut)}
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
fritfald
2019-01-24T09:03:39Z
I get this as an output (Standard):

. /progs/fks/b/batch/jobs/bstl_tjek.sh aka00029 -p 19.02.2019

Last login: Wed Jan 23 14:14:01 2019 from 172.23.10.10

ratata.foa.dk> is$ . /progs/fks/b/batch/jobs/bstl_tjek.sh aka00029 -p 19.02.2019
ratata.foa.dk> is$ . /progs/fks/b/batch/jobs/bstl_tjek.sh aka00029 -p 19.02.2019
job: aka00029
db: fiksbdb
prdato: 19.02.2019
12
SSH Task returned error 12 from server.
I use the 12, its the Exit Code, but is it possible to grab or get hold of the text "job: aka00029" and use it as a variable fx in a textfile name?
Support
2019-01-24T13:18:58Z
You should use regular expressions for this. We do not have any regex-expert in-house but you should combine the output with regular expression Variable (once you have found the correct regular expression:

{REGEX(Match|{TASK(PrevTask|StdOut)}|REGULAREXPRESSIONGOESHERE)}
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Gary_W
2019-02-12T14:57:35Z
The regular expression would be:

{REGEX(Match|{TASK(PrevTask|StdOut)}|^job: .*)}

The regex meaning:
^ - anchor to the start of the string
job: - Match the literal characters "job: " (includes the space)
. - followed by any character
* - followed by zero or more of the previous character

So based on your comment, I think what you really want to do is create a job variable called maybe JobTextFilename, than after the SSH task, create an Internal/Set job variable task with this answer as the value.
To save just the "aka00029" part of the string, use MatchGetGroup, Which lets you group a part of the match with parenthesis, then refer to it numerically from left to right as the group to return.

{REGEX(MatchGetGroup|{TASK(PrevTask|StdOut)}|^job: (.*)|1)}
Scroll to Top