So I'm trying to get input from the user, specifically their password before we run some commands through sudo. While using gradle to execute the shell script it prints out to the console something like
$ > Building > :gradletaskname
But when it asks for a password or other input it is not intuitive because the way gradle writes to the console it looks like the following.
$ > Building > :gradletasknamePassword:
I have tried echoing new lines but it always displays like my example above. I know this might be a silly question but I've been beating my head on this for a while now.
It's a known limitation and will be fixed in one of the next releases. Here's a link to the JIRA issue: http://issues.gradle.org/browse/GRADLE-1147
Related
I have a shell script where I am running a multiline command to fetch version from our UI.
Command I am using is:
var=$(curl -k myurl| awk something | sed something)
Then I am using the var for further validations.
The above shell is not promoting the correct response. I checked running this in my terminal and command seems fine but this is not working with Jenkins.
Can someone please help me to understand how to solve this issue.
I have gone through multiple posts but no help.
As you mentioned, it is working on your terminal, then it should also work on your Jenkins shell, can you be more brief by sharing the error or difference in response you are getting ,
But anyways as an alternative to this, you can save your shell command in a script file, and execute it using Jenkins.
I have a simple incron task setup to run a command whenever a particular .json file is written-to, then closed.
/var/www/html/api/private/resources/myfile.json IN_CLOSE_WRITE,IN NO LOOP /var/www/html/api/private/resources/run_service.sh
I can see that whenever the file to written to, there is a syslog entry for the event, and the command that was triggered - along the lines of <date> - incrond: CMD (/var/www/html/api/private/resources/run_service.sh).
But nothing seems to happen...
initially I thought this would be caused by an issue with the script, but replacing the script command to something simple such as echo "hello world" > /tmp/mylog.log still yields no output or results. I seem to have hit a brick wall with this one!
Update
Changing the incron command to read "/bin/bash /var/www/html/api/private/resources/run_service.sh" now seems to triggering the script correctly, as I can now get output from the script.
A simple mistake on my part, despite all examples online showing that using the script as the command should run it, for me it only works if I explicitly call bash to execute it
"<my directory/file to watch> <trigger condition> /bin/bash /var/www/html/api/private/resources/run_service.sh
Problem:
I'm using Terminator but I think this question is relevant to any terminal.
To be more precise let me please explain my problem on concrete example.
I'm running Android cts tests, so I need to use cts-tradef script. This is how it looks like:
The script just runs jar (which I don't want to modify), however I would like to change color of cts-tf, so it looks like on a picture below:
My unsuccessful attempts to solve the problem:
For now I've tried doing something like this:
echo -e "\033[01;32m" && ./cts-tradefed
However it will color everything (as on below picture) while I want to color only cts-tf string (as above):
I also tried using sed, however although it works and replace some strings it also finishes cts-tradefed, so it's useless to me. Same thing (cts-tradefed finishes) happens when piping it through grep:
./cts-tradefed | grep --color "cts-tf\|$"
Another try was with grc tool mentioned by Anthony Geoghegan. Running it without config file doesn't do anything but cts-tradefed doesn't finish but when I run it with config file cts-tradefed finishes the same as with grep or sed. My config file was ok, since it works good with cat or similar commands.
I haven’t used it myself but Radovan Garabík’s Generic Colouriser looks like it should do what you want. It’s written in Python “for beautifying your logfiles or output of commands”.
Packages are available for Debian-based operating systems but I imagine it should not be too hard to install if you are familiar with Python.
GitHub repository
I am looking to automate an interactive install process with ansible. This install does not have a silent install option or does not take command line arguments for the interactive questions. The question involve setting a folder location, making sure folder location is right etc for which answers might be default or custom.
I looked into the expect module of ansible but seems like it does not solve my purpose.
- expect:
command: passwd username
responses:
(?i)password: "MySekretPa$$word"
I don't need the command but it's required. Instead I am looking for something that could regex Are you sure you want to continue [y|n]? [n]: for which I want to send the default out By sending return or typing n as a response and for example Backup directory [/tmp] for which the response would be Carriage return.
I don't need the command but it's required. Instead I am looking for something that could regex Are you sure you want to continue [y|n]? [n]:
The module requires a command because you have to run something to get any output.
You obviously do have a command in mind, because you've run it manually and seen the output it produces. That's what you should be plugging into the module.
Alternatively, you can write a pexpect script yourself and use the command or shell modules to run it.
I've figured out a way that works for me. I piped in the arguments to the shell script which when run manually needs the answers. Like ./shell.sh <<< 'answer1\nanswer2\n' which works perfectly for me. This I have added to the task.
Is there a way to add an entry to OS X's /var/log/install.log file from within a shell script?
Optimally the method wouldn't require root access as I don't think I'll have it.
The problem I'm having is I'm executing a shell script as part of an installation-check (p15 of Apple's Distribution Definition XML Schema) step from within an OS X installer package via the Javascript System.run() command (p30 of Apple's Installer Javascript Reference), but I can't see any output from that shell script.
I know the shell script is executing, because when I use the "logger" command from within the script, my log text appears inside /var/log/system.log. But in order to get a complete picture of what's going on, I'd need to merge it by hand with /var/log/install.log, which is where the general output of the installer, and any Javascript logging I do, ends up.
Any help would be appreciated. I've tried using the "logger" command's -f flag to use /var/log/install.log, e.g.
logger -f /var/log/install.log sometext
...but no dice; sometext still gets added to /var/log/system.log.
Read up on bash scripting.
You can add a line to a file like this
echo "My line here" >> /var/log/system.log
If it gives a Permission denied error, you need root access.
OK. Long time passed, and I found out the following.
In normal scenarios, anything written by pre and post install scripts (mine are python and bash) to stdout will be logged by the installer daemon to the /var/log/install.log. I experimented various tools to create my installer packages, and they usually did this.
However, in my own deployment installer, for some reason, only things written to stderr get logged to the /var/log/install.log - so you might want to try that too.
A little late, but just had the same problem and was able to add logs to install.log from AppleScript using logger with the LOG_INSTALL facility:
logger -p 'install.error' "My error message"
That's not an answer per se, but maybe a hint? Installer man pages mention a "LOG_INSTALL facility", whose output is the desired /var/log/install.log
But what is this "facility" and where is it available - I can't find. I really need to write my pre/post script failures and specific scenarios to that log.