Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Execute a .sh script from Scriptrunner

Hello guys,


I am trying to run a .sh script from a post function script using Scriptrunner. What I am currently doing is:

"path/ urls.txt".execute()

 Nothing seems to happen. The sh script I am trying to run is:

while read url
some stuff
echo "$url $urlstatus" >> urlstatus.txt
done < $1


Do you know what might be going wrong?

2 answers

1 accepted

4 votes
Answer accepted

Here is how I execute OS-level commands:

def sout = new StringBuilder()
def serr = new StringBuilder()
def cmd = "some command linke"
proc = cmd.execute()

proc.consumeProcessOutput(sout, serr)
log.error("Error executing command: $cmd \n$serr")
} else {"Command [$cmd] executed sucessfully with following output:\n$sout")

Now, tail your atlassian-jira.log file and see what happens, you should get some clues as to why your command didn't execute.

One thing to try ... in your command rather than rely on the sh-bang directive, try

"bash /path/".execute()

Thank you, @Peter-Dave Sheehan ! after some adaptations, the code you provided was very good basis to start from!

0 votes
Antoine Berry Community Leader Jul 26, 2019

Hi @Mihai_Perdum ,

This is the snippet I use to exec sh files : 

def command = "path/ urls.txt"
int returnCode = Runtime.getRuntime().exec(command);


Hey @Antoine Berry ,

Thanks for the quick answer. I just tried it but it doesn't work. I switched the bash script to something even simpler

while [ $valid ]
echo $count
if [ $count -eq 5 ];


so what I tried doing with the snippet you provided was : 

def command = "path/ > output.txt"

I had to remove the int variable you defined because it was throwing a cast error. 

Any other recommendations?  

Antoine Berry Community Leader Jul 26, 2019

At this point your best bet would be to check the logs. Maybe there is a system discrepancy that explains why it is not working. Also make sure your sh script is working first.


@Antoine Berry , which logs would those be? I made sure that the sh script is running. 

Antoine Berry Community Leader Jul 26, 2019

I would check the atlassian-jira.log.

Thank you but all I am seeing in the logs is:

1 error
2019-07-26 11:47:24,067 http-nio-8080-exec-14 ERROR zerobarat1 707x292x1 10o9jx6 0:0:0:0:0:0:0:1 /secure/QuickCreateIssue.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] actionId is 1

Antoine Berry Community Leader Jul 26, 2019

You would probably need to debug a bit further : 

def command = "path/ > output.txt"
def return = Runtime.getRuntime().exec(command);
log.error("command executed !")
def returnCode = return.waitFor()
log.error("with return code : " + returnCode)

In the case the command is executed you might want to add some echo in the sh file.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events