Skip to content

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…

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 …

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&#82…

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/seaf…

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…

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 e…