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

learn more… | top users | synonyms (1)

1
vote
3answers
1k views

zcat/gzcat works in linux, not on osx. general linux/osx compatibility

First the specific problem: In linux, I use zcat to list a .zip file. In osx, zcat seems to automatically append .Z to the file name. Various people suggest replacing zcat with gzcat; however, gzcat ...
0
votes
2answers
2k views

ulimit -n not changing - values limits.conf has no effect

I am trying to raise the open file descriptor maximum for all users on an ubuntu machine. This question is somewhat of a follow up to this question. open file descriptor limits.conf setting ...
0
votes
1answer
431 views

“Long service output” in Nagios gets chomped for some reason

According to this page the limit of $LONGSERVICEOUTPUT$ is 4kB, but in my case, it stops showing the rest of the output after 970 bytes of output (26 lines), where there multiple newlines no long ...
-3
votes
1answer
935 views

Unexpected EOF while looking for matching ``' - Bash Script

Here is my bash script: http://pastebin.com/9kgGYPmt Ok so simply, when I run the Bash command I get this error: http://puu.sh/6oSTW.png I really don't know why this is happening. Can anyone help? ...
0
votes
0answers
108 views

Using Jekyll with Github webhooks for automated deployment

A little background first: I'm a designer and want to serve some static sites with Jekyll. So I grabbed a vps(ubuntu 12.04) and installed nginx, ruby and jekyll. I work from a few different ...
4
votes
2answers
406 views

How to handle IP's with manual failover?

I have two identical storage hosts where the master is the only one the users can access. If the master fails, then I want to manually change the DHCP address, so instead of master points to ...
2
votes
1answer
50 views

Command which will tell me the last time a directory or any of its sub directories have been modified? [closed]

We are trying to deprecate our old Linux home folder server. We still have a few people that are actively using it though. Our plan is to change home folders that no one has used in the last six ...
1
vote
1answer
578 views

Centos syslog isn't logging to custom file from bash script

I'm trying to get a bash script to log to a custom log file using syslog on Centos release 6.5, but it always just logs to /var/log/messages like so: Jan 12 09:54:47 localhost nbsp: Test message ...
2
votes
0answers
17 views

Globally recording Bash history: Dealing with long-running commands [duplicate]

For security reasons, I'm trying to remotely log all commands that users enter into the shell. I've got it to work by using this in my global bashrc: PROMPT_COMMAND='history -a >(tee -a ...
0
votes
2answers
85 views

Why does system lag or stall after successful completion of tar backup command?

I have a script that runs backup of system files via tar as a cronjob for my server. Every time the script is being fired off, it completed the task as successful. All backups were tested and appeared ...
0
votes
1answer
73 views

Binary data in shell argument

Is there a way to safely encode / pass arguments to a shell command where the argument might be binary? I'm executing a command from within a PHP script that allows for user data. For security, ...
2
votes
4answers
240 views

Use logger in shell script

How can I use logger in a shell script? If I run ntpd -qnp pool.ntp.org 2> >(logger) in console, it works as expected. If I put it into a shell script #!/bin/sh ntpd -qnp pool.ntp.org ...
2
votes
3answers
198 views

How to parallelize the scp command?

I need to scp the files from machineB and machineC to machineA. I am running my below shell script from machineA. I have setup the ssh keys properly. If the files are not there in machineB, then it ...
1
vote
2answers
315 views

Gnu parallel & pipe

I want to send each line of a file to another program's stdin, e.g. input.txt line1 line2 line3 I want to use the gnu parallel like this (i.e. pipe each line as stdin to the more command) cat ...
1
vote
2answers
138 views

How do I iterate bash arrays and make an SCP command efficiently?

I need to scp the files from machineB and machineC to machineA. I am running my below shell script from machineA. I have setup the ssh keys properly. If the files are not there in machineB, then it ...
1
vote
2answers
128 views

Redirect to stdin instead of argument when using xargs [closed]

for exmaple, using the command cat foo.txt | xargs -I{} -n 1 -P 1 sh -c "echo {} | echo" The foo.txt contains two lines foo bar The above command print nothing.
0
votes
1answer
500 views

sh bash script ambiguous redirect pid of file using single quotes

I have the following new line in my .sh file su --session-command='$javaCommandLine & >>$serviceLogFile 2>&1 & echo \$! >$pidFile' $serviceUser || return 1 When I had it ...
0
votes
5answers
837 views

Bash script to check if a public HTTPS site is up [closed]

I'm trying to setup another block of code to a bash script to check if a public website on HTTPS is up or not. Can we do this using CURL? Any suggestions what can be used besides CURL. Thanks
1
vote
1answer
50 views

How is the . operator related to | and >?

I'm writing a script that transfers files that are periodically added to a remote server. To do this I'd like to pull ls output from the remote server, then check it against a list of files that have ...
1
vote
1answer
64 views

Script won't do what it should when run with cron

I've got some problem. I have script execution scheduled but when time comes nothing happens. #!/bin/sh TIME=`date +"%d-%m-%Y"` cd /var/www/flyer/data/www/ mysqldump -u root -ppasswd --databases ...
1
vote
0answers
80 views

linebreaks between results in grep

I need to occasionally monitor a spider that I have running on my server. I'm testing it to see how many iterations of it are running concurrently and to see if any of them are hanging. I use this: ...
1
vote
0answers
131 views

SNMP error reporting to stdout

Why does net-snmp after "No Such Object available on this agent at this OID" errors exit with 0 and print the error message to STDOUT while other errors are printed to STDERR and have an exit status ...
-1
votes
2answers
82 views

Compare installed rpm packages with available?

I would like to find the vmware packages that I haven't installed from their repo. The problem is that the output of yum search vmware is not the same format at from rpm -qa|grep vmware. Question ...
3
votes
3answers
1k views

Log commands executed over ssh

I would like to log all commands executed over SSH. Say, ssh something@server.com COMMAND I want to log "COMMAND" on server.com I did search extensively but could not find anything. There is ...
2
votes
3answers
328 views

How to add SSH known host in a bash script?

I am creating a bash script to provision a new server that I can deploy a web application to. One thing I always have to do is as GitHub as a known host using ssh git@github.com. How can I automate ...
1
vote
3answers
619 views

How to accurately check if package is installed in yum?

I keep getting answers like: yum list installed | grep bind or rpm -qa | grep bind But that is not accurate as I'm getting a list of few other bind packages like these: ...
-1
votes
1answer
391 views

Bash : Reload home directory (/etc/passwd) without logging out

I'm on a Debian Wheezy, and I'm wondering how I can, after editing /etc/passwd (actually to change a home directory, but nevermind), reload the user session without logging off. I tried exec bash, ...
1
vote
1answer
2k views

Insserv rejected the script header

I was trying to make an init script for my debian install for supervisor. insserv: Service \$remote_fs has to be enabled to start service supervisor insserv: Service ...
1
vote
1answer
56 views

cp/rsync command with destination as symlink to a directory

I am working on a cPanel backup solution at the moment. We are now informed about this exploit. Exploit : Full ROOT ACCESS to server 1.) create malicious file from, normal user account: mkdir root ...
0
votes
1answer
251 views

nagios bash script/command returning null

I wrote a simple nagios command to check the change of a value over 1 second #!/bin/bash HOSTNAME=$1 COMMUNITY=$2 OID=$3 WAITTIME=1 echo "/usr/lib/nagios/plugins/check_snmp -H $HOSTNAME -C $COMMUNITY ...
2
votes
2answers
214 views

executing .bash_profile alias via SSH

I would like to remotely execute a .bash_profile alias, but I cannot find the proper command. I tried: ssh user@host "bash -ic myalias" but it doesn't work I get: bash: cannot set terminal process ...
0
votes
2answers
63 views

This script won't execute on startup, ideas?

The distribution is RHEL 5. The script has been added to chkconfig like so: # chkconfig --add script # chkconfig script on But it refuses to start when taking up the machine, what could be the ...
1
vote
1answer
92 views

Wrangling sed to find and reformat login date (or, how to kill idle mosh-server processes)

I have an old method of killing idle mosh-server processes, which doesn't work on my new VPS. Here's the old method, which I run in root's crontab to clean up mosh processes that have been idle for ...
-1
votes
2answers
90 views

What user is the script run as after Carbon Copy Cloner ends scheduled task?

On Mac OS X I keep data on a local server mirrored with the same data on a remote server with a scheduled backup task done with Carbon Copy Cloner. After the backup is done a bash script is run as ...
0
votes
1answer
229 views

Replace an IP address with it's whois using bash

I have a traffic log similar to this "page visited" for xxx.xxx.xxx.xxx at 2013-10-30 and I would like to replace the ip address with the result of it's whois lookup. I can export the ip addresses ...
0
votes
1answer
391 views

Is it possible to auto update php.ini via a bash script? [closed]

I'm trying to write an install script and i need to change the sendmail line in php.ini but I want to do this automatically at the moment I'm doing this manually: sudo nano ...
0
votes
1answer
73 views

Netcat: connection lost before transfer is complete

Interesting thing with Netcat (nc) in CentOS 5 or 6 (nc-1.84-10.fc6 or nc-1.84-22.el6.x86_64). How can I work it around? I can't find a bug about this, but It models a file transfer to a remote ...
3
votes
1answer
566 views

How to detect if mount point exists from init.d script?

After a reboot, I'm executing an application from a mounted network share (autofs) using an init.d script. The script starts by waiting 30 seconds before attempting to execute the command, in order to ...
1
vote
2answers
74 views

Long string insertion with sed

I am trying to use this expression to insert the contents of one text file into another after a give string. This is a simple bash script: TEXT=`cat file1.txt` sed -i "/teststring/a \ ...
0
votes
2answers
56 views

Bash -x to file and email

I have a script that issues a lot of commands. I wish to save the output of this script (Errors and stdout) to a file, but I also want the actual commands that were executed to be saved to the file as ...
0
votes
2answers
47 views

Change/Deactivate the shell for an amount of users on SUSE Enterprise Server

I have a SUSE Server to which ~300 users are connecting. About 100 of them have to be deactivated. I think it would be nice to change their shell to /bin/false either with chsh or with usermod. ...
-1
votes
1answer
42 views

Bash syntax, square brackets and -d option

I have this command in bash: [ -d node_modules/phantomjs ] || npm install -g phantomjs I am not sure what it means in plain English... Can anyone please advise?
1
vote
0answers
99 views

grep is inconsistently defaulting to grep -P?

I have a script that does some housekeeping that works perfectly well when invoked from an interactive shell, but did nothing when invoked by cron. To troubleshoot this I started a shell with a ...
0
votes
1answer
126 views

How can I measure the cumulative network usage of a process, from execution beginning to end

I want to measure how much bandwidth git pull uses, preferably by prefixing git command with desired program, i.e. nettally git pull Alternatively, is there some sneaky way to accumulate nethogs / ...
1
vote
3answers
163 views

Override path to binary for particular user

My question seems to be trivial but I didn't manage to find anything helpful in internet. I have a binary in /urs/bin/binary but it is outdated and newer version is available on some mount for ...
2
votes
1answer
82 views

possible /how to obtain the return code for a command executed before the last command?

Linux bash (or other shell.) Have you ever fat fingered "echo $?" into something like "echo $4" thereby permanently preventing you from knowing the return code for the previous command? I do this ...
1
vote
3answers
1k views

Running ssh-agent from a shell script

I'm trying to create a shell script that, among other things, starts up ssh-agent and adds a private key to the agent. Example: #!/bin/bash # ... ssh-agent $SHELL ssh-add /path/to/key # ... The ...
0
votes
4answers
90 views

How can I make ls and xargs combined omit path

I have a folder called lib. In that folder are some files. I want to obtain all the names of the files that end in .jar, and concatenate them into a line, separated by spaces. I don't want the path ...
-1
votes
1answer
44 views

specify multiple filenames in one line. bash

guys. im trying to add to logrotate files from a some directory. it should be either *.txt files or *_log files. wtat's the right syntax for this: /var/www/html/groupware/horde_logs/[*.txt|*_log]{ ...
-10
votes
1answer
88 views

Stop server maintenance [closed]

I am ssh'ing into the remote CentOS server with Bash. I was trying to stop port 8080 and so I typed stop 8080 with "root" privileges. Now, the server is scheduled for maintenance in 8080 minutes as ...