Community forum

Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
Offline fritfald  
#1 Posted : Thursday, January 17, 2019 2:00:06 PM(UTC)
fritfald

Rank: Paid support

Joined: 1/16/2019(UTC)
Posts: 14
Denmark
Location: Aarhus

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?

Edited by moderator Tuesday, February 12, 2019 10:19:34 PM(UTC)  | Reason: Not specified

Offline Support  
#2 Posted : Friday, January 18, 2019 11:21:07 AM(UTC)
Support

Rank: Official support

Joined: 2/23/2008(UTC)
Posts: 10,781

Thanks: 812 times
Was thanked: 406 time(s) in 386 post(s)
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!
Offline fritfald  
#3 Posted : Thursday, January 24, 2019 10:03:39 AM(UTC)
fritfald

Rank: Paid support

Joined: 1/16/2019(UTC)
Posts: 14
Denmark
Location: Aarhus

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?
Offline Support  
#4 Posted : Thursday, January 24, 2019 2:18:58 PM(UTC)
Support

Rank: Official support

Joined: 2/23/2008(UTC)
Posts: 10,781

Thanks: 812 times
Was thanked: 406 time(s) in 386 post(s)
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!
Offline Gary_W  
#5 Posted : Tuesday, February 12, 2019 3:57:35 PM(UTC)
Gary_W

Rank: Paid support

Joined: 12/19/2016(UTC)
Posts: 146
United States
Location: Michigan, Dearborn

Thanks: 31 times
Was thanked: 49 time(s) in 41 post(s)
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)}

Edited by user Tuesday, February 12, 2019 3:59:16 PM(UTC)  | Reason: Not specified

thanks 1 user thanked Gary_W for this useful post.
Support on 2/12/2019(UTC)
Users browsing this topic
Guest
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2019, Yet Another Forum.NET
This page was generated in 0.219 seconds.
Scroll to Top