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

learn more… | top users | synonyms (1)

1
vote
0answers
29 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
37 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
12 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 ...
-4
votes
1answer
35 views

Bash script to move certain files to specific directories? [on hold]

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
60 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
38 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
12 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 ...
-2
votes
0answers
16 views

Converting a hobbit/xymon bash script to python [closed]

I have this bash line that I want to convert to python. $BBHOME/bin/bbhostgrep $TESTNAME | while read IP HOSTNAME OTHER; do How would I convert this to python? TIA usaims
1
vote
0answers
31 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
39 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
43 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
63 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
50 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
42 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
2answers
52 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
37 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
51 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
36 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
18 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
131 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
0answers
29 views

bash NOT reading .bashrc on RHEL 7 [migrated]

machine A --RHEL 7 and updated. machine B -- RHEL 6 and updated. If I do this on A (RHEL 7) ssh B I get in, like I should, but my .bashrc has NOT been run. This is new behavior to me. I want ...
-2
votes
0answers
37 views

How can I capture two columns of ls output in a bash script [migrated]

I want to create a script to delete any directories with numeric groups. What I have so far captures and analyzes the group: #!/bin/bash re='^[0-9]+$' for x in `/usr/bin/ls -l /var/indexes | sort ...
0
votes
1answer
37 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
119 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
27 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
54 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/ ...
-3
votes
1answer
44 views

How can I execute sibling scripts outside the directory? [closed]

$ ls -l bin/ $ ls bin/ startup.sh shutdown.sh I wrote a script named restart.sh inside the bin/ looks like #!/bin/sh sh ./shutdown.sh sh ./startup.sh Now the bin/ directory looks like this. $ ls ...
0
votes
2answers
50 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
1answer
37 views

Checking the history of www-data user [closed]

While normal users have a .bash_history in their home directory, the www-data user does not have a home directory. As such, are there any means to track the history of the www-data user?
2
votes
2answers
76 views

bc: using “scale” with bash variable [closed]

Easily, I'm writing a script that needs some values with 2 digits after floating point. Trying to use bc I don't understand how use "scale", i.e. A=12 ; bc <<< $(($A/5)) it's correct, but ...
-1
votes
1answer
28 views

Why does ssh -f create multiple processes when a pipe is used? [closed]

When I on my Linux host do ssh -f 10.10.47.47 "/opt/omni/bin/mbuffer -4 -v 0 -q -I 8024 | /usr/sbin/zfs receive tank/test" then I see on the remote host 27349 ? S 0:00 bash -c ...
1
vote
0answers
35 views

Script to restart service fails for most of the time

I have created a script that restarts a FTP service (a java program) if this value of below command is not zero: find /home/files_to_send -name "*.pdf" -cmin +10 | wc -l My problem is that while ...
-1
votes
1answer
29 views

Bash shell copy files on the hidden directory [closed]

Need help with Unix script. how do you use /bin/cp to copy files from /somepath/somedir/somewhere/.temp_folder to /somepath/somedir/somewhere/ my line /bin/cp -r somepath/somedir/somewhere/.[!.]* ...
0
votes
0answers
28 views

name of script within a init script

I'm trying to figure this out. i have /etc/init.d/startup inside the startup script I'm doing a few things: (or i will like to do) creating a PID file that should look like: /var/run/startup.pid ...
1
vote
1answer
119 views

Different bash path variables when using ssh script vs interactive ssh [closed]

I'm trying to run some ruby (bundler/rvm) commands via a script using Plink. I noticed that it was complaining about not knowing where some commands were. It seems as though my $PATH variable ...
0
votes
0answers
56 views

Barnyard2 error on start

Been setting up a snort box with barnyard2, run into the error below. Can someone please help? $Starting Snort Output Processor (barnyard2): ./barnyard2: 35: ./barnyard2: barnyard2: not found ...
-1
votes
2answers
34 views

set bash alias from bash script (not command line)

Differently from bash shell (for create new alias): alias test="echo test" if I do the same thing using a bash script, alias does not run: #!/bin/bash alias test="echo test" also export it, same ...
0
votes
1answer
64 views

Execute a service as a specific user under ubuntu

I'm running a gameserver and want to start it on a screen on system start, but screen is user specific, so I have to run the command as 'user'. So I wrote this short service script which starts itself ...
0
votes
0answers
43 views

What is a safe alternative to wildcards in /etc/sudoers?

In the /etc/sudoers file on my Red Hat server, I have this line: %webdevgroup ALL=NOPASSWD: /bin/chmod * /home/http/* This is clearly a bad idea, since someone could do something like this: sudo ...
-1
votes
1answer
137 views

Bash Script - Expect does not send password that ends with $!. Also need improvement to report connection timed out

Update: Password issue is fixed and connection timed out message was fixed too. Adding \ before $! worked. Example: *password\$! set passwds { *password\$! @tempP@ss %Test4%} For connection timed ...
1
vote
2answers
376 views

Expect script error send: Spawn id exp4 not open while executing

Update: Working code added here for others CREDITS to : http://serverfault.com/users/30957/glenn-jackman @Glenn I'm sorry! just apologizing and I mean it! Sorry Glenn your code need few changes ...
3
votes
3answers
60 views

How to pass command output as several arguments to another command

I have a command that produce a output like this: $./command1 word1 word2 word3 I want to pass this three words as arguments to another command like this: $ command2 word1 word2 word3 How to pass ...
0
votes
1answer
49 views

Mass disable customers in OTRS

The problem is about OTRS customers. I can't use an external customer backend, so I want to update the customer DB via CSV files. I already wrote a script to add new Customers via ...
0
votes
1answer
28 views

Send email on ldap creation

I have an LDAP server setup on a server running Debian 7 and I wanted to make it send out an email whenever a new user was created on that LDAP. I thought a cronjob would be best, but I have no idea ...
0
votes
1answer
90 views

Cron occasionally fails with “grandchild #X failed with exit status 3”

I have cron jobs and every now and then they fail. Just after log message that the command has started, there is grandchild #X failed with exit status 3 message. On the next run scripts finishes ...
0
votes
3answers
45 views

Modify config file settings from bash [closed]

I need to modify a config file from a bash script, changing the values of particular settings. I need to make the change using common Linux tools (sed/awk/tr/etc.). The config file can have ...
1
vote
1answer
76 views

How to grep a continuous stream, with paging

I posted this to Superuser but got no takers: http://superuser.com/questions/832578/how-to-grep-a-continuous-stream-with-paging I want to take a log file and filter out some irrelevant log entries, ...
0
votes
1answer
32 views

How to check the existence of multiple directories?

I have a script which obviously faulty: if [ -d "$BACKUP/${DATE_MAX}_"* ] then ... fi This script would only work if there is a single or no directory there at all. If there are multiple ...
2
votes
1answer
73 views

Apache - add http headers to requests, using script (bash, perl, php etc) to set the headers

I trying to work out the feasibility of a project where I want to be able to have a script run on every request (preferably filtered by mime type), and a script run to set the headers for the ...
1
vote
1answer
71 views

Why deployment sh script don't fails on failed nginx reloading?

I have sh script that restart nginx like the following: #!/bin/sh -e set -e error_exit() { d=$(date '+%D %T :: ') echo "$d Error: $*" >&2 exit 1 } if ! sudo service nginx ...