Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

0
votes
3answers
25 views

Is there an automatic way to add group read permissions to “nohup.out” when “nohup” is run?

I run my Java code from bash script using a command like this: exec nohup "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" com.myClass "$@" & Which creates the output file nohup.out and this ...
1
vote
3answers
21 views

Looping until background process is done (with `jobs`) doesn't work in script

I'm trying to loop until a background process (launched earlier in the script) is complete. An easily reproducible test case is: ping -c 10 localhost &>/dev/null & On the command line, I ...
0
votes
0answers
13 views

shell script to generate a log file for VM Backups

we are using PHD virtual backup to trigger backups for VMs and now i want to generate a report of all VMs in a file consisting of VM Name, Date and Backup Time and mail it to my ID at particular ...
-1
votes
1answer
15 views

batch Script for Fetching maximum size file from directory [closed]

I need batch script for fetching only maximum size file form one directory and delete all file form the directory except the maximum size file..
0
votes
0answers
40 views

Why am i getting execute binary file error?

i am getting following email every 10 min. as I own the VPS. I am not expert in linux and am learning to manage linux servers. Please help me why am i getting these emails and how to stop them or how ...
1
vote
1answer
45 views

Bash: better way to output to both console and output file than tee?

What I need to display is a log refreshing periodically. It's a block of about 10 lines of text. I'm using |tee and it works right now. However, the performance is less satisfying. It waits a while ...
0
votes
1answer
30 views

How to execute multi-line ssh command stored in a variable

Context: I'm trying to execute a bunch of commands on a remote machine that I cannot access directly - I first have to ssh into a gateway machine, then ssh from there and run the commands. Basically ...
0
votes
0answers
17 views

+Merlin FW / Port Forward via IPtables?

I have 2 WiFi Thermostats, Heatmiser, that i can control remotely, from LAN without issues, but only one from WAN. The thermo have a fixed port that cannot be changed and there is an App thet can be ...
0
votes
1answer
27 views

$RANDOM in script vs. on command line

I think I found a really odd bug in Bash's random number generator ($RANDOM). Showing is easier than telling, so here's what happens: The goal is to get random digits. If I execute this, I get 20 ...
0
votes
0answers
11 views

Having trouble building Vagrant bash script

I'm trying to set up a bash script provision to help build my virtual machine with Vagrant, but I'm clearly doing something wrong. Unfortunately the Vagrant docs don't provide any examples more ...
-1
votes
2answers
50 views

simple loop not working

A simple script now="$(date +'%d_%m_%Y')" path="/var/www/vitalii/backups" sites=("site1.ru site2.ru site3.ru") for i in ${sites[*]} do echo "$path/$i" #tar -cvzf $path/$i_${now}.tgz ...
0
votes
0answers
17 views

Spawn new consoles from script and get back to the main console instance

The goal is to use a script to launch and execute a command in n separate window terminal: (I use lxterminal) It works when I copy/pase the following block of commands, It executes each lines ...
0
votes
0answers
46 views

how to grep exact pattern

I’ve tried several grep / egrep ideas with different options but none worked here. I’m trying to grep exact match of the pattern I’m looking in a log. For example I want only a pattern “ERROR” to get ...
0
votes
0answers
11 views

Curl should be quit but it returns ever something

I tried to login to a website using curl in a bash-script. It is possible to login to the site quiently using this: curl -d "username=$username&passwd=$passwd" -c $cookiefile ...
1
vote
0answers
15 views

Grep from Log & Calculate then alert

I have a log file, which has the below lines in it. I need a bash script, which takes the values in Bold (4092.1M / 20.1G) & do the math & then alert from Zabbix [Eden: ...
0
votes
1answer
92 views

Require bash script to be run with sudo (not as root user)?

I want to require a bash script to be run as the current user with sudo, but prevent it from being run if it was executed as the root user directly. This is because I'm doing some setup actions for ...
1
vote
1answer
52 views

[: -gt: unary operator expected

I have a code, which gives [: -gt: unary operator expected, when the value is empty. Can anyone please suggest or correct me where I'm wrong ? if [ -e $POSFile ]; then # Read last Position ...
0
votes
1answer
27 views

BASH associative array rearrange keys

I am running into a weird issue with associative arrays in bash. I have the following files in a directory: ls -lart drwxr-xr-x. 3 root root 4096 Feb 9 11:14 .. -rw-r--r-- 1 root root 3275 Feb 9 ...
0
votes
1answer
19 views

How to detect ips using nmap?

I am currently working on demonstrating Man in middle Attack foe which I am using my phone as a Victim and my PC running ubuntu 14.04LTS as attacker. I am using nmap to ping my phone to check if its ...
12
votes
2answers
425 views

Difference when using backticks in double quotes and single quotes in Bash

Why to the following two executions differ in output? (I need double quotes for variables in my eventual command) $ sudo su -c "echo `cat /root/root_file`" cat: /root/root_file: Permission denied $ ...
0
votes
0answers
46 views

Bash function only works when password manually input

At work I have to run the following function everyday. The function works fine when I am prompted for the password. However, I tried to hardcode my password so that I don't have to enter it in each ...
0
votes
4answers
90 views

How do I DELETE a comma and a space from a numeric string using a bash script

Folks, I have asked this question 5 times on here and have received 5 separate bits of code from super users that have all *failed. Problem: I have stock information being brought back into a txt ...
0
votes
1answer
31 views

Bash script failure

I have this script. It works fine on one of system but it's giving some error on another machine: 1 #!/bin/bash 2 EXEC_DIR=`dirname ${0}` 3 source ${EXEC_DIR}/config.sh 4 5 ...
0
votes
1answer
44 views

I want to append the name of the file on the top of that file using bash script

I want to add void mainfunction() on the top of a file. I am reading the actual name of the file from another file and the name of the main function from another file. I was using: sed -i 1i void ...
1
vote
1answer
65 views

Bash loop through all directories within a directory and if find any instance of string in each directories specific file do this

I have a service that utilizes a unique user specified port for remote connections. I install multiple instances of this service and wrote a bash script to automate the installs. My installer has a ...
0
votes
2answers
41 views

bash: How to use a quoted argument in select

From a command I get some arguments that I want to offer to the user with the select statement from bash in a shell script. The arguments supplied by the command may contain spaces and are therefore ...
1
vote
1answer
44 views

How can I use the pipeline output from different commands inside a custom bash script?

I have this simple script: #!/bin/bash # This command removes the last "\n" (line feed) character from the file specified as parameter # # Params: # $1 [FILE_NAME] - the name of the file to trim if ...
2
votes
1answer
621 views

How to update bash on Mac OS X Yosemite

Just trying to learn bash scripting a little. My old bash version: Bash version 3.2.53(1)-release... I've updated my bash on mac os x yosemite with homebrew: brew update brew install bash Then ...
1
vote
1answer
199 views

Bash script to execute jar with parameters and using file path variables

I am trying to run the following bash script and it gives me the following error #!/bin/bash -x jars= $HOME/SelGridProto/selserversidedjars java -jar $jars/selenium-server-standalone-2.44.0.jar ...
2
votes
1answer
37 views

Check for Free Space on Linux, email if critical

I just finished dealing with a server which had run out of space, and would like to setup monitoring on it now, to prevent it going critical in the future. What I would like is to get an email sent ...
3
votes
2answers
53 views

opening several terminals at once

In my dev environment, I sometimes need several terminals to be open, each running its own script/ a server (rails, django, redis, mongo, consoles, etc) How can I create some shortcut that will open ...
0
votes
1answer
49 views

Launch a bash sub-shell and expect a command

From a shell script, how can I launch a bash sub-shell for the user & wait for the user to type exit at the bash sub-shell prompt? I tried bash -c expect -c 'expect "exit" {send "Exiting\n"}'; ...
1
vote
2answers
31 views

Is there a way to pass arguments via pipe on bash?

Is there any way to pass arguments via pipe on bash? something like: echo value1 value2 | mkdir -p ./$1/$2 The line above would create the directories ./value1/value2 If this is not possible I ...
0
votes
1answer
18 views

Move spam emails from directory - bash script

I am trying to write bash script wich can cleanup my whoole server from spam emails that already are present in my client's folders. I would need this script to do, Check recursively directory ...
0
votes
1answer
52 views

Bash on android [closed]

I have a rooted sony z2 smartphone and I'm able to run sh scripts, I also have busybox installed but I'm unable to work out how to run bash scripts, I've tried ls -l /bin/bash from terminal and get ...
0
votes
1answer
39 views

Without eval command does not run correctly

just something that i can't seem to figure it out. Begginner bash scripter here I wrote a script to accept command line parameters that are later passed to maven Here's is the working version of the ...
0
votes
1answer
19 views

i need to pass a string of an output file to a variable so as i can use it globally all over my script [closed]

sample output RETENTION_INTERVAL ------------------ 10080 I need to pass the numeric value "10080" from the output file to a variable .The condition should validate value and ...
0
votes
0answers
10 views

avoid sigstop in script bash

alias notesave=' cwd=$(pwd) && cd ~/Desktop/Notes && git add * && git commit -a -q -m "-_\@" && git push -q origin master && echo "DONE!" && cd $cwd' ...
0
votes
0answers
25 views

Bash script monitor file modification after its closed

It has already been asked here and I have found the solution for the first part of my question. So for the moment I have a bash script (script1) where I evaluate the sha1sum of a specific file ...
0
votes
1answer
25 views

'hhighlighter' wrapper script saying command not found

I have gotten the wrapper script 'hhighlighter' from https://github.com/paoloantinori/hhighlighter which colors anything you want in stdout. I followed the instructions about installing ack-grep, ...
0
votes
1answer
22 views

Append text at the end of a specific line

I have a file with multiple lines. What I am trying to accomplish is add a string at the end of a commando. I have a script that installs a tool automatically. Now some things have changes in the ...
1
vote
1answer
82 views

Format terminal output to show apt-get upgrade errors in RED

I have a VERY simple bash script written for my Kali Linux distro so I don't have to run apt-get update, apt-get upgrade, apt-get dist-upgrade, apt-get autoclean, and apt-get autoremove every time I ...
2
votes
3answers
125 views

How to open one GNU screen tab for each directory in a list

I have the following script - it sort of works. #!/bin/bash ... define plugins, etc for plugin in ${plugins[@]}; do screen -t $plugin done Want I want it to do open gnu-screen and for ...
0
votes
0answers
76 views

Monitoring xinput keycodes in bash

So basically, what I'm trying to do is use the xinput command to watch for keyboard input in the background for a bash script to toggle things. I would like to ideally monitor multiple different ...
1
vote
1answer
93 views

Executing PHP file from command line with dynamic parameters

I need to run one script which will take one date as an argument. It is configured using cron to run on a daily basis, but I need to run it for a time range now. The issue is that this will fetch all ...
0
votes
2answers
64 views

Use “read” in Bash script with a standard answer

How can I use read with something as standard response, which the user can change though? (a default answer)
1
vote
1answer
16 views

Homebrew script to reinstall formulas

I'd like to develop a bash script to capture the currently installed Homebrew formula, then be able to reinstall these formulas in the event that I need to reinstall my OS. I'm hoping to combine ...
2
votes
1answer
24 views

Unset bash variables referring to non-existent directories

I have a file which is sourced by an application, adding relevant directories to $PATH and $LD_LIBRARY_PATH. This is fine, but it results in somewhat excessive pollution of the $PATH and ...
0
votes
1answer
107 views

Detect window's fullscreen status on Linux?

So basically, I'm trying to write a watchdog script, that checks window titles against a list stored in a file. If the window is fullscreen, the script should do nothing and move on. If the window is ...
0
votes
1answer
47 views

Passing different set of arguments to the different commands in a linux bash script

I am writing a bash script foo.sh that runs too commands bar with first input argument, and baz with the second argument: #! /bin/bash bar "$1" baz "$2" Now I want to make foo.sh more flexible, ...