Strange mismatched quote problem trying to run a shell command from script console

6 views
Skip to first unread message

Adam von Nieda

unread,
Dec 20, 2018, 10:13:32 AM12/20/18
to jenkins...@googlegroups.com

   Hi folks,

   I’m trying to run a local shell command from the script console, and a mismatched quote error is kicking my butt. The entire command is surrounded by double quotes, and the command executed from the “-c” is surrounded by single quotes. There’s not a typo, I swear! Any ideas? The strange this is that it only seems to happen if there’s multiple items separated by spaces in the single quotes. If I do a single executable like ‘ls’, that works fine. 

import hudson.util.RemotingDiagnostics
import jenkins.model.Jenkins

def String target_database = "testdb"
def String version = "7.6.5.4"

def sout = new StringBuffer(), serr = new StringBuffer()
def proc = "sudo su oracle -c '/home/oracle/scripts/datapump/refresh_database.sh ${target_database} ${version}'".execute()

proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println "STDOUT\n $sout"
println "STDERR\n $serr"

STDOUT

STDERR
testdb: -c: line 0: unexpected EOF while looking for matching `''
testdb: -c: line 1: syntax error: unexpected end of file


Reply all
Reply to author
Forward
0 new messages