I have added Shell Script (in post build Task) which executes CURL statements.
The Curl statements gives some output which I want to refer later in my Shell Script, currently I am unable to achieve this.
Is there some way wherein it can be achieved.
I have searched for plugins but dint find any satisfactory answer to the requirement.
You can get the text as follows:
def proc = "<your culr command>".execute()
echo proc.in.text
You can use the shell syntax to capture this output:
curl_output=$(curl http://your.curl.query)
echo $curl_output
You will capture everything in your variable. Then you can use it whenever you want.
This is also working if you are calling a shell script:
output=$(./yourscript.sh)
echo $output
Your variable will catch everything that you echo during your execution
Related
I have a bash script that do checks and show result correctly in local server
but when using graphic web of Centreon the message is empty
I use echo as output of function called from main
Thanks for all, the problem it is when i run script in Nagios-Centreon
i have this outpout NRPE: Unable to read output in OS AIX
the code is large, i resolve it by changing #!/bin/ksh instead of
#!/bin/bash
Basically the problem is because of special caracters in script shell.
https://support.nagios.com/kb/article/nrpe-nrpe-unable-to-read-output-620.html#:~:text=This%20error%20implies%20that%20NRPE,when%20running%20the%20remote%20plugin%20.
I have a variable $svn_tag in a Jenkins job.
Its value is branches/sprint-77.
I want the output branches-sprint-77, but I didn't get any output.
I tried these two methods:
$svn_tag|tr "/" -
${svn_tag////-}
It is giving output in bash script, but it is not working in the Jenkins job.
What am I doing wrong?
Your first approach does not make sense, not the least because you try to run `$svn_tagĀ“ as a command. Your second approach works for me:
svn_tag=branches/sprint-77
echo ${svn_tag////-}
prints branches-sprint-77.
For the safe side, you could also check your bash version, by doing a
echo bash=$BASH_VERSION
though I don't think that this feature is version-dependent. Mine is 4.4.12(3)-release.
Use code like below
${svn_tag.replaceAll('/', '-')}
I have rather complex bash script which is normally run manually and thus needs live output on the console (stdout and stderr).
However, since the outcome and output of this script is rather important I'd like to save its output at the end into a database.
I have already a trap function for this and the database query as such is also not a problem. The problem is: How do I get the output of the entire script till that point into a variable?
The live console output should be preserved. The output after the database query (if any) does not matter.
Is this possible at all? Might it be necessary to wrap the script into another script (file)?
I'm doing similar task like this
exec 5>&1
message=$(check|tee /dev/fd/5)
mutt -s "$subjct" "$mailto" <<< "$message"
Add your script instead of check function and change mailing to db query.
This might be a naive question, but I'm really not sure how to do it. I submit a spark job and I get the following output.
Run job succeeded. Submission id: driver-20170824224209-0001
I want to programmatically query the status of this job. How can I use the output in the console to extract the id to a variable using a bash script.
Any help appreciated.
Let's say you command is cmd and you want to store the output of the command in ( say ) a variable called res, one way in bash is to run the command in single quotes
res=`cmd`
or embed the command within $()
res=$(cmd)
Capture both stdout and stderr in Bash
I can't figure out how to get output from shell script back to rtorrent after command has been executed.
Is it possible to return back output from exeternal command back to rtorrent session?
I use rtorrent scripting interface to auto execute shell command after torrent is finished
event line in .rtorrent.rc looks like this:
system.method.set_key = event.download.finished,mycustomcommand,"execute=~/myshellscript.sh"
myshellscript.sh file looks like this
#!/bin/sh
echo "Torrent finished!"
Is there a way to do this?
I'm not sure what you're searching for, but I found this on rtorrent's wiki site:
execute_capture_nothrow={command,arg1,arg2,...}
This will execute the external command with arguments arg1,arg2,.... It will return the
stdout output of the command.
system.method.set_key = event.download.finished,mycustomcommand,print="$execute_capture=/path/to/script"
should work, at least
print="$execute_capture=/path/to/script"
works when you do it inside rtorrent. If you want to store the output then intstead of print use d.custom1.set= if that helps.
You forgot to add parameters to the rtorrent.rc itself and also the bash script is incomplete according to me.
.rtorrent.rc line should have
method.set_key = event.download.finished,whatever,"execute2={/path/myscript.sh,$d.name=,$d.base_path=,$d.hash=}"
bash script
#!/bin/bash
TORRENT_NAME=1
TORRENT_PATH=2
TORRENT_HASH=3
touch "$1" Finished download!
exit
this will create touch file telling you particular file has finished downloading.