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

learn more… | top users | synonyms (1)

-3
votes
0answers
20 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
16 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 ...
0
votes
0answers
5 views

OS X LoginHook - nc exits prematurely for no apparent reason [migrated]

I'm trying to use loginhook to download large amounts of data and I've been having problems which I've nailed down to nc exiting prematurely for no apparent reason. This is a simplified test script: ...
-3
votes
0answers
24 views

What you want to see in daily linux server monitoring mail? [on hold]

I write bash script, which collect information from ubuntu server and send it by mail. With this script you can see: Your clamav antivirus information Which ports are open How many users in your ...
-2
votes
0answers
13 views

Pam modules: some troubles understanding things [on hold]

I recently started to study PAM and for the moment I am having troubles in understanding an entry from /etc/pam.d/sshd (among others). auth required pam_unix.so ... ... ... account required ...
1
vote
0answers
26 views

How to make Supervisord read bash environment variables [on hold]

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
19 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
0answers
22 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
36 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" ...
-4
votes
0answers
14 views

Bash script to create directory from one server to another [closed]

Looking for help to create bash script which runs on a server and upon providing the directory path and other server names(ssh enabled), creates the directory on other servers
0
votes
3answers
50 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 ...
0
votes
0answers
12 views

Quoting / escaping / expansion issue in “command in a variable” [migrated]

I want to run a command such as this in a bash script: freebcp <authentication and other parameters> -t "," -r "\r\n" When run directly on the command line, the command works as expected. But ...
0
votes
0answers
25 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
33 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
42 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 ...
0
votes
1answer
32 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
20 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 ...
-3
votes
1answer
56 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
54 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
0answers
3 views

Drawing an histogram from a bash command output [migrated]

I have the following output: 2015/1/7 8 2015/1/8 49 2015/1/9 40 2015/1/10 337 2015/1/11 11 2015/1/12 3 2015/1/13 9 2015/1/14 102 2015/1/15 62 2015/1/16 10 2015/1/17 30 ...
0
votes
0answers
18 views

Different result from a bash function [migrated]

I am trying to code a script to log all commands executed on a server, currently I have 2 versions: (simplified version of the scripts) Version 1: function fc { fc -ln -0 } trap fc DEBUG ...
0
votes
1answer
50 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 ...
0
votes
0answers
6 views

VLC script on ubuntu server [migrated]

I need a small script which run three vlc command on the same time (on Ubuntu server 14.04) as stated below: #!/bin/sh cvlc -vvv v1 --sout ...
0
votes
0answers
19 views

bash: !": event not found in Ubuntu 13.04 [duplicate]

I am facing the following error bash: !": event not found while i have write the following command, echo "Hi,There!" >> test.txt whats the problem?
1
vote
1answer
16 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
30 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
87 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 ...
1
vote
1answer
38 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
49 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
25 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
68 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
74 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
43 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
16 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
46 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 ...
1
vote
2answers
41 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
65 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
69 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
58 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
72 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
73 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 ...
4
votes
1answer
57 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
107 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 ...
0
votes
1answer
58 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 ...
2
votes
2answers
20 views

Is it possible to determine if a job is being started as an at job (kicked off via atd/cron)?

Is there a way to identify a script is being run as an at job instead of interactively from the shell by a user? Some of our scripts have a guard to check if they're running in screen by checking ...
2
votes
3answers
167 views

One line script to check and react to memory usage

I'd like to have one line of shell/bash that does something along these lines: test "`free | grep | awk | whatever` -gt 80" && any_command Where the total percentage of ram being used by ...
0
votes
1answer
84 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 = ...
3
votes
3answers
148 views

Setting up FQDN in sendmail [closed]

In this blog post he suggests echo '127.0.0.1 localhost EXAMPLE.my_domain localhost.localdomain EXAMPLE' >> /etc/hosts but ends the post with But this is a less desirable approach ...
-3
votes
1answer
30 views

Display only some of the lines of the lsof command [closed]

I am trying to create a bash script for displaying only certain lines of the lsof command. I have figured out that the lsof command itself lists information in the form of columns which show info ...
-2
votes
1answer
97 views

How to open sftp connection and execute sftp command in the same shell command [closed]

Is there any possibility for opening sftp connection to remote server and execute sftp command in same line from shell. Something like this: sftp user@example.com && put /tmp/test.txt /tmp/ ...