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

learn more… | top users | synonyms (1)

4
votes
6answers
2k views

Prune duplicate entries from PATH variable

I modify my .bashrc frequently and then source it. However, when I have things like export PATH="~/bin:~/perl5/bin:$PATH" in my file, then the PATH environment variable grows every time I source the ...
0
votes
1answer
121 views

Using Jekyll with Github webhooks for automated deployment

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 computers throughout the day, so I ...
2
votes
1answer
67 views

How can I detect if I have access to a resource on an FTP server?

I'm trying to write bash script for file copying from local machine to FTP using lftp. Problem is, when someone enter inaccessible path for mkdir or put, then lftp returns: Access failed: 550 /: ...
0
votes
1answer
44 views

Include executed cron command when outputting to log

Is there a way I can include the command that was executed in the output when I'm logging to a file? For example: * * * * * date && /path/to/php /path/to/script.php >> cron.log ...
10
votes
7answers
5k views

create 'virtual file' from bash command output?

I wonder if there is a way to create a 'virtual file' from a bash output. Example: Let's say I want to email the output of mysqldump as an attachment to an external email address. I can use Mutt to ...
1
vote
6answers
618 views

SSH and redirection

Consider the following command: ssh aristotle sudo /bin/sh < test.sh I want the redirection to apply to /bin/sh but it is consumed by sudo. Any ideas on how to achieve what I want?
1
vote
3answers
2k views

GNU Screen and .bashrc

I am trying to launch GNU Screen using my .bashrc. I'm almost there: if [ -z "$STY" ]; then exec screen -dR else exec gnome-terminal fi This is wrong though! The first case works, screen ...
9
votes
2answers
4k views

What is the best way to set an environmet variable in .bashrc?

When setting up a variable in .bashrc should I use this: export VAR=value Or would this be enough: VAR=value What is exactly the difference (if there is one)?
0
votes
1answer
41 views

Use tmux for managing multiple downloaders as a supervisorctl service?

I have many data-servers I need to download data from via http as soon as it is available. For each server I start a bash "while true"-loop and within that a wget to poll the server for new data. To ...
1
vote
0answers
71 views

Wrong PATH in init script on boot

Since the update of the System on my Synology NAS (x86), I have some problems with my startup scripts. The Bash scripts are stored in /usr/local/etc/rc.d. The scripts were executed for sure, because ...
1
vote
1answer
19 views

pipe rrd to a new directory

I am chrooted and running out of drive space, so I mounted back to the host drive which has plenty of space but cannot seem to redirect the outputted data to my empty drive [root@localhost rra]# ls ...
1
vote
1answer
54 views

Refine grep look behind to avoid numbers

When I query docker images, I get this: #> docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE local/debian 7.5 172c7702a46f ...
1
vote
1answer
32 views

name of script within a init script

I have a script /etc/init.d/startup, where I do the following: creating a PID file that should look like: /var/run/**startup**.pid executing a screen of a java process, so I will like to create the ...
2
votes
0answers
120 views

Trying to script rsync using pam_exec

I'm trying to write a bash script that will execute rsync when called by pam_exec. I've tried a couple different ways, and I'm not sure what I'm doing wrong. When I try to run the script at login by ...
2
votes
0answers
88 views

use socat to provide password to bsign

I have many servers, where I deploy various binaries. For this purpose I use a script that packs them into archives, publishes to the local repository and then ssh-es to the target servers and ...
2
votes
0answers
116 views

error in killing tshark from shell script

I'm getting this error: *** glibc detected *** /usr/sbin/tshark: double free or corruption while doing as below, any idea why? #!/bin/bash trap 'my_exit; exit' SIGINT SIGQUIT count=0 ...
2
votes
1answer
168 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 ...
2
votes
1answer
90 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: ...
2
votes
1answer
98 views

Implementing and testing a Subversion hook

Background I'm trying to implement a number of commit hooks for Subversion. I have done a lot of research to try and get a simple test hook to work, however I have had no luck. For reference I have ...
1
vote
0answers
30 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 ...
3
votes
1answer
205 views

Encrypting/Decrypting a file using openssl through an autorun script

So I am trying to encrypt/decrypt a file using openssl. I am running it through a script that is automatically run when I mount a USB, and decrypts the file. However, it doesn't work quite right, so ...
1
vote
3answers
39 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
13 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? [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 ...
1
vote
6answers
2k views

Make ls print it all on one line (like in terminal)

ls prints differently depending on whether the output is to a terminal or to something else. e.g.: $ ls . file1 file2 $ ls . | head file1 file2 Is there some way to make ls print out on one line ...
3
votes
2answers
2k views

Bash script throws error “read error: 0: Resource temporarily unavailable”

My Script throws the error read error: 0: Resource temporarily unavailable the second time user input ( Unix Username ) is expected. I suspect this has something to do with the first background ...
3
votes
1answer
63 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 ...
19
votes
2answers
5k views

Why does redirecting 'script' to /dev/null/ allow 'screen' to work while su'ed as another user?

I was su'ed into a user to run a particular long running script. I wanted to use screen but I got the error message "Cannot open your terminal '/dev/pts/4' - please check." So I Googled around and ...
-1
votes
1answer
39 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 ...
13
votes
6answers
43k views

How can I edit the welcome message when ssh start?

I have a vps for my website hosting. It is running a ubuntu server. Every time I logged in my server by ssh, it displays a lengthy welcome message in my terminal. Linux node61.buyvm.net ...
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 ...
0
votes
1answer
970 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" ...
6
votes
3answers
6k views

iftop - how to generate text file with its output?

iftop is great tool to view almost live bandwidth usage distinguished by source-ip source-port destination-ip destination port. I'm using it to see which client's ip is using most bandwidth. Now I ...
2
votes
1answer
1k views

Linux- Permission denied?

I'm installing Neo4j server as a linux service, but when I install it, I get the following message: /sbin/insserv: Permission denied What is this? What should I do? I'm running everything with ...
6
votes
3answers
5k views

How do I exclude a folder when performing file operations i.e. cp, mv, rm and chown etc. in Linux

How do you exclude a folder when performing file operations i.e. cp etc. I would currently use the wild card * to apply file operation to all, but I need to exclude one single folder. The command ...
1
vote
0answers
33 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
44 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
2answers
889 views

Meaning of killall -0

I see from many place the follow command is used to check if a process exists, e.g. killall -0 nginx But from the documentation I can't see anything related to this argument, can anyone explain?
5
votes
5answers
2k views

Send message to IRC channel from bash

I have installed ircd-hybrid on my Ubuntu Server (192.168.1.2, example.com). We use #teamchannel to communicate inside the team. The question is: how can I send some short message from example.com to ...
2
votes
4answers
1k views

How to get the mount point of flash drive by using uuid?

I am beginner in ubuntu linux and i need to write simple bash script, that can identify necessary flash drive(which contains only one vfat partition) using uuid of this partition, and get the mount ...
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
51 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 ...
2
votes
3answers
132 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 ...
12
votes
3answers
9k views

Using bash, how can i find out the average, max and min from a list of numbers?

I have a series piped greps, awks and seds which produce a list of numbers, one on each line. Something like this: 1.13 3.59 1.23 How can i pipe this to something which will output the average, ...
0
votes
1answer
92 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
1answer
45 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. ...
4
votes
1answer
38 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
37 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
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 ...