Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).

learn more… | top users | synonyms (1)

-1
votes
1answer
19 views

Monit not able to start program in screen

I have monit able to watch the program but the start script is not working. The stop script works just fine. The when monit tries to start it, it just says execution failed. Monit part check ...
0
votes
0answers
27 views

IP not showing in /var/log/secure under rhost

I'm trying to get Fail2Ban to block failed sudo -i commands, but the IP is not showing up in the logs. For example when I log into the server with: ssh -i ~/.ssh/id_rsa USER@1.2.3.4 I then use: ...
7
votes
2answers
10k views

how to filter rsyslog messages by tags

I have several applications and scripts that I want to redirect the output to custom files. I launch those applications using command | logger -t TAG I would like to filter these messages based ...
14
votes
5answers
6k views

SSH from A through B to C, using private key on B

I'm looking for a simple way to SSH from my local machine, A, through a proxy, B, to a destination host, C. The private key that goes with the public key on C is on B, and I can't put that key on my ...
-1
votes
0answers
6 views

oSX 10.11 running on vmware player sudo mount error on mount() =-1 error on sudo [on hold]

I have oSX 10.11 running on vmware player and I am trying to make it full screen. I am following this tutorial here: https://www.youtube.com/watch?v=46GL3YW-r50 However I am having this error:
43
votes
6answers
105k views

How do I sleep for a millisecond in bash or ksh

sleep is a very popular command and we can start sleep from 1 second: # wait one second please sleep 1 but what the alternative if I need to wait only 0.1 second or between 0.1 to 1 second ? ...
187
votes
5answers
72k views

What is the difference between double and single square brackets in bash?

I just wondered what exactly the difference between [[ $STRING != foo ]] and [ $STRING != foo ] is, apart from that the latter is posix-compliant, found in sh and the former is an extension ...
-1
votes
0answers
9 views

configure: error:UPnP code has been disabled, Could not find crypto++ header file

I use Centos 6 (6.7)I want correct this command (is wrong) [root@ultimi aMule-2.3.1]# ./configure --prefix=/usr --with-denoise-level=4 --enable-optimize --disable-debug --enable-cas --enable-wxcas ...
0
votes
1answer
52 views

Bash Script Not Working

I hope this is an easy answer Problems: I placed the following bash script called learn-address.sh in the following folder: vi /etc/openvpn/netem/learn-address.sh Added the following (2) ...
56
votes
8answers
18k views

bash: print stderr in red color

Is there a way to make bash display stderr messages in red color?
0
votes
2answers
31 views

bash: splitting stdin to multiple processes,merging outputs, ensuring known completion/output order

Consider the following simplified version of a function that converts column data spat out by a terminal program into JSON... side note: the second example might be quicker to read, to understand my ...
1
vote
1answer
2k views

Nginx how to run shell script on page load via lua module os execute and then serve directory listing?

So I have a bash script that I want to execute/run on each "page load" of url so that it will modify (creating symlinks) to a /public/html/ folder that I want the server to then serve. The problem ...
0
votes
1answer
17 views

Creating a RFC 1123 compliant date for HTTP header creation on the CLI

I'm trying to create a HTTP 1/1 compliant date header using standard unix date(1) in order to post this to a RESTful server using curl or similar. Any ideas what format to pass to date(1) to get this ...
0
votes
0answers
6 views

When did bash's shopt huponexit start defaulting to off? [migrated]

On Monday morning, I logged into a box with ssh and ran the following command: tail -f /var/log/foo/bar.log | grep something_interesting & At some point later in the day, I logged out by ...
19
votes
5answers
31k views

Multi-select menu in bash script

I'm a bash newbie but I would like to create a script in which I'd like to allow the user to select multiple options from a list of options. Essentially what I would like is something similar to the ...
0
votes
0answers
8 views

Check files since latest git fetch/git pull

When command git fetch --tags --progress ssh://mygit/repos/repo.git +refs/heads/*:refs/remotes/origin/* is done, there is a following output detected: remote: Counting objects: 21, done. remote: ...
0
votes
1answer
13 views

Bash remove exact matching variables and search for string ignoring case

First Query: i have a text file username.txt contains user1 user2 user3 My Bash file is as follows > test.sh #!/bin/bash # REMOVE user which donot have any COMBLIMIT num=0 cat /tmp/username.txt | ...
0
votes
1answer
1k views

Monit failed to start shell script

So I am having a problem with monit starting a process this is my code: check process program_1 matching "program_1" start program = "/home/user1/files/start.sh" stop program = ...
1
vote
1answer
20 views

xinetd read post data

I'm trying to write a simple handler for a webhook using xinetd and bash. I have the trivial case working with this config for xinetd: service github-hooks { port = 61000 ...
-1
votes
0answers
24 views

how to fill the cpu cache forcefully

Is there a simple (bash based) way to forcefully fill up the cpu cache on linux with some dummy contents? I am comparing the timings of two programs and would need to make sure the cache content is ...
1
vote
2answers
1k views

Inserting multiple lines into a sqlite column with bash script

I am trying to insert a value into my sqlite DB that consists of multiple lines and special characters. For example: { "foo"="$BAR" } I have been using the sqlite3 command but I dont know how to ...
0
votes
0answers
10 views

Find Unknown Predicate JailedShell

Well, after months experimenting with ', ", and \" it seems i cant find the right pattern that could generate the correct code for a cron job on a jailed shell. I got this code below works on jailed ...
1
vote
3answers
52 views

Error when passing string to scp in for loop

I'm grabbing file list from server via find via ssh for f in `ssh -p ${SSH_PORT} -l ${SSH_USER} ${SSH_HOST} -t "find ${DIR_REMOTE} -type f | grep jpg" 2> /dev/null` When I echo the list in the ...
0
votes
1answer
1k views

OpenVPN run script after tunnel is set up

I'm having a hard time figuring out exactly how can I update my A records on my cloudflare account. I have already set up a script that checks for IP changes, and pushes the changes through the ...
20
votes
14answers
40k views

Stop ssh login from printing motd from the client?

I've got SSH passwordless set up, however it prints the MoTD when it logs in. Is there anyway to stop that happening from the client side? I've tried ssh -q but that doesn't work. I don't want to use ...
5
votes
5answers
8k views

Kill all processes that are running for more than 5 minutes by a given user in linux bash script

I need the command to kill processes that have been running since at least 5 minutes for a given process. I will have to run that command every five minutes or so. Thanks a million ! (system is ...
0
votes
1answer
26 views

Globbing based on current directory

Ran into some strange behavior today. Wondering if anyone here can tell me what is behaving differently. Environment is a RHEL 6.7 server. I run the following command: yum list installed *mysql* If ...
0
votes
1answer
53 views

ps aux | grep result depends on terminal size on FreeBSD

From experimenting, it seems that even when using ps aux | grep ... the output depends on the terminal size. This seems seriously weird for me. Isn't a pipe supposed to make command's output behave ...
1
vote
1answer
44 views

Ansible & rbash

I want to manage a bunch of devices running /bin/rbash as the default shell with Ansible. The problem is that Ansible always tries to execute a list of commands that rbash doesn't like at all: umask ...
1
vote
1answer
612 views

Can't restart mysql from cron job

I have a problem where MySQL (running on Ubuntu 12.04 with all latest updates) dies after a few days so put this script into a cron job that runs as root every 60 seconds. Everything works except ...
15
votes
6answers
36k views

How to remove invalid characters from filenames?

I have files with invalid characters like these 009_-_�%86ndringshåndtering.html It is a Æ where something have gone wrong in the filename. Is there a way to just remove all invalid characters? ...
1
vote
1answer
27 views

How to test if a mounted share is still functional

I have a set of linux machines with samba ( and other ) shared drives. There are automated scripts that mount these shares. My problem is, sometimes a host machine will go offline, but I can't find a ...
1
vote
1answer
25 views

Loading Blacklist of IPs from a file into IPTABLES

In a separate file I'm creating a list of IP addresses to be blocked. This file will have IPs added in or removed on a daily basis. I want to "reference" this IP File into /etc/sysconfig/iptables, but ...
7
votes
4answers
12k views

Using sed to remove both an opening and closing square bracket around a string

I'm running this command in a bash shell on Ubuntu 12.04.1 LTS. I'm attempting to remove both the [ and ] characters in one fell swoop, i.e. without having to pipe to sed a second time. I know square ...
1
vote
1answer
51 views

linux command has different behaviour in script

(Question SOLVED and edited for helping someone else that need it or have the same mistake, now with the code in the post for better readability) I am trying to create a script that does something if ...
5
votes
0answers
2k views

Can't write to other users “you have write permission turned off”

For some reason I'm not able to write to other users on my system. [root@hostname ~]# write write: you have write permission turned off. [root@hostname ~]# mesg y [root@hostname ~]# mesg is y ...
4
votes
1answer
61 views

openldap user can't login when using tcsh

I would appreciate any help in the following problem: I have an openladp (2.3.39) server (Fedora 8) which authenticates users from other ldap clients (various versions of Fedora). On my attempt to ...
0
votes
1answer
1k views

Using curl with cookies

I hope someone can help me out on this one. I have been trying this for a while now, with all sorts of variations and cannot seem to get this to work. I am trying to script a way to log in to ...
2
votes
1answer
1k views

Improper output in SSH session on OSX using FreeSSHd on Windows with cygwin bash/sh shell

I am testing out running an SSH server on a local Windows VM. I have installed FreeSSHd and set the command shell to "c:\cygwin\bin\sh --login -i" (bash as well) with "Use new console engine" ...
8
votes
3answers
195 views

Bash one-liner to atomically create a file if it doesn't exist

I want a Bash one-liner that atomically creates a file if it doesn't exist. That means essentially "if file doesn't exist, create it" but ensuring that no one else manages to create the file in the ...
34
votes
5answers
10k views

Can you have more than one ~/.ssh/config file?

We have a bastion server that we use to connect to multiple hosts, and our .ssh/config has grown to over a thousand lines (we have hundreds of hosts that we connect to). This is beginning to get a ...
11
votes
2answers
16k views

Writing to stdin of background process

I'm on an Ubuntu 10.04 box, and started a server in the background (myserver &) over ssh. It's been running fine, but I need a way to get at the server's stdin, as the only way to control the ...
8
votes
3answers
8k views

Can't run AWS CLI from CRON (credentials)

Trying to run a simple AWS CLI backup script. It loops through lines in an include file, backs those paths up to S3, and dumps output to a log file. When I run this command directly, it runs without ...
33
votes
4answers
27k views

Check if array is empty in Bash

I have an array which gets filled with different error messages as my script runs. I need a way to check if it is empty of not at the end of the script and take a specific action if it is. I have ...
5
votes
1answer
4k views

How to change default shell in FreeBSD?

The default shell in FreeBSD is sh and I really can't stand it: autocomplete is very limited, and rehash commands kill me. I feel like a one armed and one legged man... How can I change the shell ...
2
votes
1answer
1k views

JBoss EAP 6.2 on RHEL 6: ./bin/init.d/jboss-as-standalone.sh hangs while calling via SSH

I'm using jboss-as-standalone.sh to manage JBoss EAP standalone as a service. I can start/stop the service with "service jboss-as-standalone.sh start/stop" while I'm on a terminal. But I would like ...
1
vote
3answers
31 views

Calculating the percentage of the total available memory on linux as an integer in bash

Here is a bash script that is calculating 80% of the total RAM available as an integer on a Linux box: server_ram_mb=$(awk '/MemTotal/ {printf( "%.2f\n", $2 / 1024)}' /proc/meminfo) echo ...
1
vote
1answer
43 views

ZFS Send Script works when run manually but not in Cron (Already tried common solutions)

Script on sending end is as follows: #!/bin/sh #Variables bigdata=vid-zfs-live/bigdata today=`gdate +%m-%d-%y` yesterday=`gdate -d'yesterday' +%m-%d-%y` #Actions zfs snapshot -r ...
0
votes
1answer
34 views

Log all bash actions with multiple scripts

Using the command below, I can log all actions that happened inside that script. bash -x script.sh Sadly, the script calls another script, which does not have the -x setting active then, i.e. the ...
-1
votes
2answers
37 views

Script to delete older files and copy what is left

We have a server that runs an application that is used internally. The application has a utility that creates its own backups every 24 hours. Backups are stored in: ...