Skip to content
Advertisement

Tag: shell

Bash script unexpected result for while loop

I have following bash script to stop Apache server. I am not getting error but an unexpected result. I got the following answer which I do not expect to be, with an infinite printing: I expect to print: Could anybody please tell me what is happening? Answer This doesn’t work the way you seem to think it does: You want

Why does “/usr/bin/env bash -x” only work in command line?

I am playing with a docker CentOS image, and find executing “/usr/bin/env bash -x” command is OK in terminal: But after writing this command into a script and execute it, it doesn’t work, and prompts “No such file or directory”: Is there any difference between two methods? Answer The short answer is that you only get one parameter to the

escape alarm() process timeout with nohup or setsid?

I have a monitoring application, Zabbix agent, that allows me to run arbitrary commands/scripts and grab the return value. The agent is configured with a timeout and any command that exceeds the timeout will be killed. For every command that is run, it first sets the timeout via alarm(timeout) and then forks the agent process before running the command in

How to send a message to another user via Bash

I am writing a shell script, and I need to send a message to the other user. If I write write user1 in trem, and then write the message and use Ctrl + D, the message will send to user1’s trem successfully. But I want to use a .sh file to send the message to user1 automatically, and I encountered

jq in shellscript: parse argument with ‘-‘

Here’s the json I need to parse: And my code to parse is like the following: The problem is this part: I can’t get the value of it and I guess the reason is that I didn’t pass $var correctly? I also tried But it doesn’t work..Maybe the tiny ‘-‘ in the “config-$val” made it special? So my question is

Bash script commands not running

I have seafile (http://www.seafile.com/en/home/) running on my NAS and I set up a cron tab that runs a script every few minutes to check if the seafile server is up, and if not, it will start it The script looks like this: running /home/simon/seafile/seafile-server-latest/seafile.sh start and /home/simon/seafile/seafile-server-latest/seahub.sh start-fastcgi individually/manually works without a problem, but when I try to manually run

How to enable confirmation alert when using ‘rm’ command to delete files / folders? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question

Until Loop not working as expected

I’m currently learning Linux and as an homework, we have to create a few basic shell scripts. Nothing especially complicated but this one is giving me headaches. Here’s my code : Basically, I have another script called afficher.sh (I’m french so don’t mind the french language used) and it reads whatever file name it gets as a parameter. However, the

sed – insert line after X lines after match

I have the following contents: Using sed, I want to insert line at the INSERT LINE HERE label. The easiest way should be: find text “function_1” skip 3 lines insert new line But none of the known sed options do the job. inserts new_text right after ‘function_1’ inserts new_text after each of the next 3 lines, following ‘function_1’ inserts new_text

Advertisement