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

learn more… | top users | synonyms (1)

3
votes
8answers
97 views

list linux partition names only in bash

df on linux lists the following stats on partitions. -bash-4.1# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 1918217320 1473337340 347440136 81% / ...
-1
votes
0answers
32 views

How can I run as another user? [migrated]

This is the bash code that should be runned. So first it substitutes the user to openproject and than runs all the code su openproject -c "bash -l" cd ~/openproject git checkout Gemfile.lock git ...
2
votes
3answers
45 views

Can I use Bash interpreter in service/daemon scripts?

I'm writing a Debian/Ubuntu service that should start on at runlevel 2-5. Most of the existing services I came accross are written using /bin/sh (Shell) interpreter while /bin/bash (Bash) offer lot ...
2
votes
2answers
80 views

/bin/sh: difference between variable and direct command

Imagine i have following bash script: #/bin/sh #next line will work correctly, outputting user name and current directory start-stop-daemon --start --exec /bin/su -- root -c 'whoami; ls' ...
0
votes
1answer
32 views

Binding timestamp value to a variable in crontab

I'm basically trying to declare a variable with a date() value in crontab as I will constantly be using the same date structure over and over, here is what my crontab looks like so far. php = ...
2
votes
0answers
30 views

Writing content from a file to another file on set time intervals using delimiters [migrated]

I'm trying to write a script in bash that reads a file(file1) and writes to another file(file2) every 2 seconds which is easy enough. However, I want to write to file2 on either a line by line basis ...
-2
votes
1answer
60 views

Bash script to install packages and report to log file [closed]

I want to be able to log result of running bash script to file. Script itself is pretty simple, its used to install basic packages on fresh install machines and it scheme looks like this sudo apt-get ...
2
votes
1answer
56 views

Bash script match grep output and send message

I am developing a script for monit status checking so I can send OK status messages to NagiOS NSCA server (passive checks). The problem I am having is that my bash script still sends messages if the ...
0
votes
2answers
49 views

Assistance with bash functionality

I need to access data from a server that is behind a proxy. Thus, I can normally ssh to the proxy and then ssh to the destination to perform administration. However, not sure how to achieve this in ...
1
vote
1answer
24 views

BASH: append loop output to an email [closed]

I want the output of this script to be a body of the email message but I don't want to redirect it to a file first and then to an email, basically no external login/output files - all action should be ...
0
votes
7answers
144 views

better way to loop through a list of servers

I regularly do things where I loop through a list of servers to take some action. For example: for s in `cat servers.txt` ; do echo; echo $s ssh $s 'do something' done I'm wondering (from a ...
1
vote
1answer
47 views

rsync not deleting Folders in destination

I know there are some questings with the same topic here but no answers helped me. First, this is my script. It should copy all files from the source to the destination (preserving all rights, etc). ...
0
votes
0answers
20 views

Odd behaviour with varnishlog and stream redirecting

I wrote a helper to debug varnish installation and have used it on both production and development server. The odd thing is, I encountered different behaviour even though the setup is nearly identical ...
0
votes
1answer
27 views

Bash function hangs while command run perfectly without function

Following function hangs : ssh() { local RESULTS; RESULTS=$(ssh $USERNAME@$SERVER $SSH_COMMAND1); echo $RESULTS; } ssh; while if i run following commands they work fine : ...
0
votes
1answer
40 views

Bash — Using a character-based graphical utility to store output

I'm using bash to script a remote dialing program in an Ubuntu(14.04) server and I am having some significant trouble trying to read the output from it. I would like the program to execute as I would ...
0
votes
2answers
56 views

Backup Ubuntu server with cron/rsync: Problems with resuming large files

I currently have a dedicated Ubuntu backup server which wakes itself up from suspend (using rtcwake) daily. 5 minutes later a cron BASH job kicks in, using rsync to pull files from various network ...
-4
votes
2answers
39 views

Linux User generation script [closed]

Was wondering if someone could point me in the right direction. I'm wanting to create a simple bash script to create user account. The script will need to prompt the admin for a username and ...
0
votes
0answers
9 views

Ctrl-C is ignored by pppd when put in a shell script

I'm trying to connect to GPRS network through a serial port connected GSM modem. When I call /usr/sbin/pppd call <peer_name> from the command line, It correctly receives and handles Ctrl+C from ...
0
votes
2answers
43 views

How to use the new ifdown and ifup?

I would like to change the MAC address on a Fedora 2o webserver, but it seams that ifdown and ifup doesn't work like they used too before systemd were introduced. This is what I would like to do ...
0
votes
0answers
13 views

bash globbing - strange behaviour [migrated]

I was playing with bash globbing recently and I noticed the following: First, make 2 dirs: $ mkdir test $ mkdir test2 Then: $ echo test? Outputs (correctly): test2 But: $ ls test? Outputs ...
0
votes
3answers
70 views

Tail a file from ssh and mirror to a local file

To tail a file over ssh, I can use ssh -t remotebox "tail -f /var/log/remote.log" However, it is possible to sync the tail with a local file? So a file automatically mirror the update of the tail ...
1
vote
1answer
18 views

BASH: bz2 to gzip conversion with find

I would like to convert a muliply bzip2 files to gzip format. I achived this with foor loop but I would like to do the same with find: BASH for loop: for i in $(ls -1 *.bz2); do echo "Converting: $i ...
-1
votes
0answers
32 views

user input not accepted in nested case statement [migrated]

I am trying to create a nested case statement in which user input is expected (Y/N). However, the system never waits for the input and always goes to the third option, "Please answer yes or no". Can ...
2
votes
2answers
62 views

Two databases synced backup

I got a system that need two databases to work. I need a script to backup both databases at given point of time. I need databases to be in sync, so I need to be sure that backup does not allow changes ...
3
votes
5answers
180 views

Hide the output of a shell command only on success?

Hiding the output of a shell command usually involves redirecting stderr and stdout. Is there any builtin facility or command which by default hides the output but on error dumps all the accumulated ...
1
vote
0answers
38 views

Is offering extra Information in Bash Autocomplete acceptable? [closed]

I am currently playing around with a bash autocomplete module for the Yii2 php framework. Is it acceptable or taboo for the autocomplete script to offer extra advice (via stdout) on a double tab? For ...
0
votes
0answers
17 views

GNU Screen: how to start a bash process and execute a command within it? [migrated]

I'm trying to set up a screenrc file that opens a few windows, and in one of them I'd like to start a shell and start vim within it (rather than starting vim directly). I've tried things along the ...
4
votes
3answers
270 views

Understanding the different directory sizes

When comparing root@debian:~# du -s /backup/test1/ 5605364 /backup/test1/ two directories with du, root@debian:/etc/init.d# du -s /data/test1/ 5605360 /data/test1/ du tells me that there is a ...
0
votes
0answers
25 views

Linux bash command to shutdown Windows 8 machine with net Samba [migrated]

LS, I have a RasPi for home automation, and I want to be able to shutdown my Windows 8.1 workstation using a bash command. Of course I've google before asking here. And I found; net rpc shutdown ...
-1
votes
3answers
45 views

Limiting permissions of a file owner

I would like some assistance on what happens when you set the ownership of a file for the owner. AKA. chmod 400 would mean only the owner can view it and no one else can do anything with it. However, ...
0
votes
1answer
25 views

How to download a file in bash from a download PHP script? [closed]

For example, a file named nerdtree.zip that can be download by running this link in browser: http://www.vim.org/scripts/download_script.php?src_id=17123
0
votes
2answers
90 views

Script SSH to router and “enable” and run commands

I have a script that will ssh to a list of routers and run commands from commands.txt. I want to enable after I connect to the router through ssh before I execute the rest of my commands in ...
1
vote
1answer
77 views

Fork a process inside a bash shell script

I've a simple shell script like #!/bin/bash sh -c "sleep 60" & exec sleep 120 In using the pstree command, I found something like `-sleep(11681)---sleep(11682) The first sleep is due to the ...
8
votes
6answers
338 views

Find directories, where files with a specific ending are missing

I want to display all directories, that do not contain files with a specific file ending. Therefore I tried using the following code: find . -type d \! -exec test -e '{}/*.ENDING' \; -print In this ...
0
votes
0answers
23 views

pam_exec not working? cannot allocate 2 bytes?

I am trying to run a script during the login process using PAM and libpam_exec; I have added this line to the desired file under /etc/pam.d/: auth required pam_exec.so debug log=/var/log/debug ...
1
vote
3answers
57 views

locale-gen with purge does not work

I use the --purge option to remove existing locales before generating new one, but seems cannot remove existing locales? e.g. # locale-gen --purge en_US # locale -a C en_AG en_AU.utf8 en_BW.utf8 ...
0
votes
1answer
85 views

ways to automatically fix line endings in shell scripts or files who break with ^M

Problem We regularly break our files lines endings and things stop working without us noticing. Bash complains about "invalid option" or ": command not found" as described here: ...
1
vote
2answers
42 views

Rsync plugin to many local wordpress installs via script or cli

I am maintaining a large number of wordpress installs on a production server, and we are looking to deploy InfiniteWP for managing these installs. I am looking for a way to script the distribution of ...
1
vote
4answers
279 views

How to make a copy of /proc/xxxxx? [closed]

A users account have been hacked on one of my servers, where the hacker have started some spam binaries. Before I kill the processes would I like to make a copy of them, but when I tar czf ...
-3
votes
1answer
42 views

How to get count of email accounts per user in cPanel? [closed]

This question is similar: Finding out the total number of email accounts in a cPanel server which I would love to comment on, but can't because of reputation. This one-liner works well to get a total ...
0
votes
1answer
47 views

Check result from grep of apt-get and use in bash conditional

I am trying to test for information about a specific package version on Debian. However, my grep against the result from APT doesn't seem to be doing anything. I'm not sure how to write the bash ...
0
votes
0answers
28 views

Bash Script issue : Discrepancy in output when executed via cron [duplicate]

I have written a bash script that writes date and database size of a DB to a text file. The script is executed via cron every week. There is some discrepancy in the output that is being generated . I ...
0
votes
1answer
68 views

Shell script only executes partially when run with CRON [duplicate]

I've written a shell script that does the following: Retrieve mail from a POP3 account (using GetMail) Save a copy of that email to S3 (using AWS CLI) Email me the filesize of the email The ...
0
votes
1answer
49 views

Bash if statement equal output from last command

I am trying to equal something from last command with bash if statement: #!/bin/bash monit status if [ "status" != "error" ]; then echo -e "hostname\ttest\t0\t0" | /usr/sbin/send_nsca -H ...
1
vote
1answer
57 views

Replacing LineFeed \x0a with SED

I have to delete lots of Linefeeds (Hex \x0a) in a logfile. I just have sed to solve the problem. It is a bit complicated I know.. Do you have idea how to solve the problem? Here is an example ...
0
votes
2answers
57 views

Use inotifywait and lftp to synchronize servers

I have two servers: Server A (CentOS), where people can upload files to (upload root is /files) Server B (Win 2008), with FileZilla FTP Server (FTP root is C:\content) I want that whenever a file ...
0
votes
1answer
39 views

Is 'which' command always showing the right file / which binary is really being run?

I am using Ubuntu 12.04 LTS and I have apparently messed up my system with various versions of duplicity installations: first I had 0.6.18 installed from the default repo, then I tried using 0.6.23 ...
2
votes
4answers
39 views

Equivalent of grep -l for filenames in zipfile

Given a set of zip files, is there an easy way to list only those zipfiles that contain files whose names match a given pattern, cf. using grep -l to list only files whose contents contain lines ...
0
votes
0answers
25 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 ...
0
votes
3answers
42 views

tail -f AND allow text input

I want to create a script that allows some interactivity by tail -f logfile from myService allows text to be entered and sent to myService What I could not solve yet is this two functions working ...