So I’ve been having a problem with some cli programs. Sometimes when I kill the running process with Ctrl+C, it leaves the terminal in a weird state (e.g. echo is turned off). Now that is to be expected for many cases, as killing a process does not give it a chance to restore the terminal’s state.…
Tag: shell
Prevent accidental history editing in bash
I recently switched from tcsh to bash, and one thing that keeps tripping me up is how bash handles history. I regularly bring up a previous history command and begin to edit it, but realize I need to run a different command first. In bash, this edits the original command, and I cannot see what I originally ty…
How to write a bash script which calls itself with python?
Can someone explain how this bash script works? The part I don’t understand is “””:”, what does this syntax mean in bash? test running result: Answer That’s clever! In Bash, the “””:” will be expanded into only :, which is the empty command (it doesn…
Am I setting this script up correctly to run specific commands based on user input?
I have a small script that I am working on. This is only the second script that I have made using bash script. Basically what I am wanting this script to do is take the users input and fire a command based on that choice. As you can see the user first enters the host address of the instance they
How to repeat a dash (hyphen) in shell
How can I repeat the character – n times in shell? I have read and tried this, but this does not work for -. It throws error invalid option. Below is the exact command that I used: Original posted line: printf ‘-%0.s’ {1..100} I also tried escaping – by putting a but in that case it r…
Run bash whiptail script after login with sudo
I’m creating a virtual machine configuration script using whiptail that I’d like to have automatically start after the user logs in. The thing is, that I don’t want the user to be root, however because the user will need to be able to change things like hostname, ip address, add directories,…
Docker-compose – mongodb could not be authenticated
After installing Docker Toolbox on Windows 10 and starting docker-machine, I run docker-compose up, I run into this error: The following packages cannot be authenticated mongodb-org-shell The code in the dockerfile: RUN apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv EA312927 RUN echo &…
chmod: changing permissions of ‘my_script.sh’: Operation not permitted
when I’m trying to make shell script that error is shown ,what i must do ?? [sudo] password for rehamadel: [rehamadel@localhost bin]$ ls -l my_script.sh Answer Resolving the operation not permitted error: You created the file via: This means, the owner and group of the file is root. You are not allowed …
How to use source command within Jenkins pipeline script
I recently rewrite bash execution command into Jenkins pipeline. The old code is like Now I use pipeline script to wrap the command, like this However, I got an error, as…/.jenkins/script.sh: line 9: source: environment.sh: file not found. When I try to less environment.sh, it display correctly. So I su…
Get a radius of a circle in bash shell
I need to write a script to find radius of a circle and then find the area while the circumference is given The formula is: RADIUS=CIRCUMFERENCE/(2 * PI) The problem is I cant make this formula work because bash doesn’t accept decimal division I read a lot of answers there but still can’t get what…