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

learn more… | top users | synonyms (1)

0
votes
2answers
252 views

How to use environment variable in haproxy?

I work with haproxy 1.5.2 My haproxy.cfg has this server definitions: server HALB_ucd1 ${UCD1_END_POINT_IP}:${UCD1_END_POINT_PORT} check port 8444 I set the UCD1_END_POINT_IP and ...
0
votes
1answer
159 views

catch bash script output from expect, expect hangs

I currently use expect to pass password to rsync to copy files across unix servers test.sh ./expect.sh $password rsync -azvr $username@$host:$file ./$dir expect.sh #!/usr/bin/expect -f ...
2
votes
2answers
751 views

Manipulate JSON in bash

I have a JSON file I need to update a particular value. { "Comment": "comment", "test": { "enabled": true }, "enabled": true, "otherStuff": blah, "otherStuff2": blah, "otherStuff3": ...
0
votes
0answers
85 views

CentOS - how to chroot sftp and have mysql as shell

I have a user who I would like to have sftp access to one folder only (chrooted). Also he logs in with ssh, I would like him to only have access to mysql. I am able to chroot the users sftp (by ...
0
votes
1answer
123 views

Command fails during script execution in bash

I'm working on a bash script for automatize some common tasks but I'm having some issues and I need some help. This is the script I'm talking about: #!/usr/bin/env bash PS3='Please enter your ...
0
votes
0answers
151 views

Executing a remote command over an SSH tunnel

I have created a reverse SSH tunnel from computerB to computerA. On computerA I have a script (r1on.sh) with the following content: #!/bin/bash echo 'r1on' > command.log /usr/bin/ssh -p2222 ...
0
votes
1answer
62 views

lvm clone logical volumes layout to another host

I want to clone LVM logical volume layout to another host ( = Create volumes with same size ). Does anyone know solution for this ? I know I can execute something like: sudo LC_ALL=C lvs -o ...
9
votes
1answer
1k views

reboot multiple machines remotely

I need to reboot a number of machines remotely. Normally I just issue for host in <hostlist>;do ssh ${host} 'sudo shutdown -r now';done But I want give the users some time before the ...
0
votes
1answer
55 views

Can't seem to create file in bash

I'm trying to use this (under the root account) code in debian 7. #!/bin/bash cat > /root/.ssh/github.id_rsa << EOF -----BEGIN RSA PRIVATE KEY----- XYZ... -----END RSA PRIVATE KEY----- EOF ...
0
votes
2answers
47 views

Remove duplicate lines in file that doesn't appear in sequence

The uniq tool isn't a good fit because it only works on duplicate lines that appear right after the previous ones i.e. in sequence. Instead, I want something that turns a textfile dupl.txt. Also, I ...
0
votes
3answers
115 views

How can a script loop for 30 days?

I have a script, backup.sh, that creates a backup of a MySQL database and then SCPs it to a remote server. This works great, and I can run this once per day using crontab with no problems. However, ...
-2
votes
1answer
264 views

How do I install lvextend on CentOS?

lvextend did not come installed on my CentOS image, how do I install it? # lvextend -bash: lvextend: command not found
-3
votes
1answer
135 views

Are these Advanced Features possible with a Bash Script on an Ubuntu Server? [closed]

I am trying to build a really flexible and useful Server Backup Bash Script. I have pretty much no experience working or building Bash scripts. I know that thousands of them exist in the wild but I ...
0
votes
2answers
188 views

Creating a log file inside a script works when manually run, but not when run through cron

I'm using Percona's Xtrabackup tools to back up a database nightly. I wrote a wrapper script to keep the proper number of backups around, write the output to a log file, and email the log file if the ...
0
votes
0answers
115 views

How to (best) configure updatedb in cygwin to search windows shares?

Context: Finding Files Quickly Across the Network A confession. I'm more of a bash/linux developer type than a windows admin. Our deployments have over 80 servers. Recently a software bug required ...
-3
votes
1answer
86 views

bash script mysql reset pass

It seems that this code is not working I tried using it on my debian 7 machine and the password it gives me is wrong. # Please confirm that you want to reset the MySQL passwords CONFIRM="n" echo -n ...
0
votes
1answer
100 views

rsync not behaving the same in script vs shell

Afternoon ServerFault, I have hit a problem that I can seem to reach a solution to, I currently have a backup script that is meant to rsync VMs off our VMWare box onto our backup server, the problem ...
1
vote
0answers
269 views

How to make Supervisord read bash environment variables [closed]

I am using Supervisord to run my java application, which requires some environment variables for configuration. I am setting the environment variables in /etc/environment export ...
0
votes
1answer
36 views

How to act upon condition of whether a file updated via Rsync was updated

I think this is simple but I can't find anything in my googling, maybe I'm searching the wrong terms. I have a machine that syncs itself to another machine. If there are changes to a file on the ...
0
votes
1answer
97 views

How to read/ modify freetds.conf (for ODBC) using augtool or similar in bash script?

How can I get augtool (augeas) or a similarly common tool to work with freetds.conf, so I can automate some configuration in a bash install script? This doesn't seem to work: augtool print ...
0
votes
1answer
162 views

sudo: unable to execute … bad address - what is it and how to fix it?

I have a set of scripts which finishes up client machine deployment after executing a fairly generic NetRestore image. The main script runs under root privileges, and then calls another, "user" ...
0
votes
3answers
621 views

postfix/dovecot - run script when mail is received

I need to implement solution on my postfix/dovecot server which will execute bash script every time message arrives. For this purpose I did following things in master.cf configuration myhook ...
1
vote
0answers
69 views

Is rbash secure if user login and ssh passwords are disabled?

I've got a server that I want to use as an SSH gateway for remote and local port forwarding. I don't want arbitrary commands to be able to be executed on it, only my scripts. I keep reading about how ...
0
votes
0answers
43 views

Nagios plugin quits when encountering the bc command— how to diagnose?

I've written a nagios plugin using the bash scripting language. When I run this script by hand it works with no issue. Putting it into a nagios plugin however, using the same parameters, leads to ...
2
votes
1answer
79 views

How to exit after starting a service in Linux for loop

I have a for loop I'm using to stop and start number of development servers here is an example. for i in `cat hosts` ; do ssh $i -i .ssh/key.key -t sudo /etc/init.d/jboss-as start ; done This will ...
1
vote
1answer
166 views

Catch all emails and pipe them all to a script with postfix

I realize this question was asked and answer before. Here's what I have done. Created a catchall address and user. Here is my /etc/postfix/virtual file. @example.com catchall Added it to main.cf. ...
1
vote
1answer
307 views

Environment variable not available in python

I have a pretty interesting problem regarding environment variables, and googling around didn't show me any meaningful results: $ echo $BUCKET && python -c "import os; print ...
-2
votes
1answer
217 views

Looking For Simple, Fast Incremental Backup Algorithm Using RSYNC [closed]

I'm running a simple bash script that uses rsync to do an incremental backup of my web server every hour. What I'm looking for is an efficient algorithm to delete the proper backups so that in the end ...
0
votes
1answer
74 views

How can I tell a script is running under cron?

Is there a standard way to know if a shell script is running under cron as opposed to running from the command line. i.e. I'm thinking of running with more verbose output when manually kicked from the ...
0
votes
1answer
112 views

Bashrc function called ssh doesn't work

I created a function in my bashrc file so that when i ssh into something it automatically opens a tmux session. function ssht () { /usr/bin/ssh $@ -t 'tmux a || tmux || /bin/bash' } This ...
1
vote
1answer
72 views

bash: Something like quotemeta() for pattern characters?

Background I am aware of bash's various string manipulation capabilities. Also, I know I can escape special pattern characters with a backslash \. For instance: # x is a literal string 'foo*bar' ...
1
vote
0answers
139 views

Running inotifywait on startup of machine

I want to start this inotifywait script on startup of the machine, in order to monitor the folders from the moment of booting: #!/bin/bash while inotifywait -r -e ...
2
votes
2answers
893 views

How to use ssh and sudo together in bash?

I haven't been able to find a question that describes this specific scenario. I am trying to execute a very basic bash script to retrieve logging from multiple machines. I am running the script ...
2
votes
1answer
115 views

WP-CLI doesn't run from cronjob

I made a bash script that uses WP-CLI and was intended to run from a cronjob. It runs fine from SSH, but fails when run through cron. During debugging I discovered that it was the WP-CLI part that ...
1
vote
3answers
205 views

How to fix a function in bash that checks if an RPM package is installed?

I've written this function: function isInstalled { if [ rpm -q $1 &> /dev/null ]; then echo 'installed'; return 1; else echo 'not installed'; return 0; fi } But something is ...
1
vote
0answers
176 views

pg_basebackup automatic password

I have a master and slave database setup. The master database is on a secure network and only the postgres port is allowed through to the slave database server. The database needs to be secured and ...
-3
votes
1answer
823 views

Bash script to move certain files to specific directories? [closed]

I'm looking for a script that can move files from one directory into another, however each file has a different name and its name corresponds to what folder it should be moved to. For example: file ...
3
votes
1answer
146 views

Cannot extract .tar.gz archive in bash

I am in my /w dir and I saved the .tar.gz archive from the MediaWiki server like this: $ cd /public_html/w $ wget releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.1.tar.gz But once I try to ...
-1
votes
1answer
59 views

Create user account on many servers

I have a users.txt with the following content: ip1 user1 password1 ip2 user2 password2 .... ipN userN passwordN I want to create one user on each of these servers. I want to use this script on each ...
1
vote
0answers
41 views

Load OpenMPI module for Apache httpd

How can I tell Apache httpd which version of MPI to use? I'm trying to run a Django web application under Apache httpd, and some of our pages make MPI calls with mpi4py. The problem is that I get an ...
1
vote
1answer
65 views

SSH issues: keyfile and host file not working as expected

When I login to server with a key ssh -i /home/me/.ssh/id_rsa server everything goes without glitch. The key is authorized on the server. However if I try to do same from a shell script, I get a ...
2
votes
2answers
47 views

Disable all outbound network

I cannot seem to find any information on how to completely disable all networking. Essentially I want to flip the switch for any outbound or inbound networking. Like the wifi button on my computer, ...
0
votes
1answer
132 views

Script to Push Files

Script to Push Files Hey Guys, Thanks for always being helpful, I have another issue that I need a little insight on how to fix. See the below script I have and the error I get. I don't understand ...
1
vote
1answer
78 views

New to bash - “Unexpected end of file”

I'm trying to set up a simple bash script to check and see if an error message appears in a log, if that error message "reset adapter" appears in that log the server is supposed to email us. Whenever ...
1
vote
0answers
80 views

How best to maintain a recent bash version on amazon linux?

I require Bash 4.2 or higher. Amazon Linux default repositories only provide Bash 4.1. I have done some searches and can not find a yum repository for recent versions of Bash. I don't want to compile ...
0
votes
1answer
149 views

Efficient way to parse Apache Access Log for CMS logins

I've been working on a way to parse large multiple access logs (sometimes in double digit GB in size) for CMSs. Right now I just need WordPress and Joomla, but I know the types will grow over time. ...
-2
votes
1answer
446 views

How to insert text from a file into another in bash [closed]

The content in fileA is: Here’s the ip list. ip: 2.2.3.4 ip: 2.2.3.5 ip: 2.2.3.6 ip: 2.2.3.7 The content is fileB is ip: 1.2.3.4 ip: 1.2.3.5 ip: 1.2.3.6 ip: 1.2.3.7 How to use sed command or ...
5
votes
1answer
206 views

How would you add a share to smb.conf via a script?

I'd like to script adding a share to a smb.conf file. My current script just appends it to the end of the file, but that's not ideal. I'd rather have something that will add a new share if it doesn't ...
0
votes
1answer
202 views

How can I return a specific exit code on the Linux command line?

I've got a program that controls a long-running process which runs over ssh on a remote machine. Frequently, I'll get disconnected in the middle of the process, so I've changed the invocation from ...
1
vote
2answers
421 views

Executing local function code on a remote server

I am updating about 20 bash scripts that perform various server-side operational tasks, checking status / sending reports etc. On some environments these scripts will run locally, on others they need ...