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

learn more… | top users | synonyms (1)

0
votes
2answers
24 views

Check if remote mysql query was successful - bash

When using a bash script to execute remote MySQL queries, how can I know if the command was successful or not. Locally it would return an exit code. However, remotely it seems to send the query and ...
1
vote
4answers
157 views

Bash: mv directory one at a time

I am trying to move all subdirectories of a folder to another share on the same server. If I do a mv *, I will run out of space since the folders are not removed until all folders get transferred. ...
0
votes
3answers
22 views

How can I copy all files in one tree to another tree except those matching a pattern?

I have a directory tree under ./src/ I have another matching directory tree under ./work/ I'm trying to copy all the files in src to work, while keeping the directory structure and excluding all ...
1
vote
0answers
27 views

Capture transcript of program with redirected input and output [migrated]

A typical interaction for a program I've written might look like this: Enter command: a_command Completed a command Enter command: another_command Completed another command I typically run my ...
-1
votes
0answers
34 views

Shell vi mode prints (arg: repetition): How to remove it? [migrated]

Whenever you are in vi command mode on the shell and hit a number, like 8, "(arg: 8)" shows at the start of the line. Anyone know how to make it not do that? The moving the line I'm typing is ...
0
votes
1answer
18 views

Bash/grep: ignore lines over N characters

I have a find/grep command that i use to search my projects' codebase, thus: find folder1 folder2 folderetc -print | awk '{print "\""$0"\""}' | xargs grep -n "search-string" Something that ...
-1
votes
1answer
20 views

how to set linux hostname based on flashdisk volume label [on hold]

i'am running live linux, which run from FAT32 flashdisk since i run a lot of pc using this flashdisk, its difficult to identify which IP for its hostname, since its ip need to be dynamically ...
0
votes
1answer
45 views

Eliminate need for grep use only awk

I am trying to generate a list of PID's to pass to strace I only want the PID's php-fpm. I can get the correct output by using grep with awk but am looking for an awk only answer. Here is what I ...
0
votes
0answers
22 views

Who have logged in the system during the last day and which command(s) s/he has executed? [closed]

I want to write a shell script to know that who have logged in the system during the last day and which command(s) s/he has executed? I need to execute in both Mac OS X and Ubuntu. But its okay to ...
-1
votes
0answers
11 views

touch -d alternative in MAC OS X [migrated]

I need to change modification time of all my files in a folder 1 hour back (daylight saving issues with some software) The thing is that touch -m -r {} -d '-1 hour' Doesn't work on MAC OS X Any ...
0
votes
0answers
37 views

wget failing when I enter variable name in command [migrated]

I have a small bash script to download a file from my webserver. I pass the $File variable through the command line and then insert it into the wget command as follows: File=${1} wget -a ...
0
votes
2answers
48 views

Capture piped multiline grep output into a variable

I'm using Zabbix's zabbix_sender.sh script to push exception stack traces to my remote Zabbix monitoring server. zabbix_sender.sh requires a key and a value for any data that it sends. It can read ...
1
vote
3answers
67 views

How do I restore the default bashrc?

I have accidentally overwritten .bashrc. I did the following echo 'export EDITOR=/usr/bin/nano' >> /etc/bashrc Bur I accidentally typed > instead of >>. I guess, it was a bad idea. I ...
1
vote
1answer
38 views

How to programatically find default ssh key?

In most of my experience, by default, ssh will look in ~/.ssh/id_rsa(.pub) for the default key pair. Ocassionally I try to write scripts to take advantage of this default key location, but I end up ...
1
vote
0answers
8 views

screenrc subshell for every window [migrated]

.screenrc: shell -${SHELL} caption always "%n(%t) %= %{b}@%H[%l] : %{r}%c:%s" termcapinfo xterm ti@:te@ termcap xterm 'AF=\E[3%dm:AB=\E[4%dm' terminfo xterm 'AF=\E[3%p1%dm:AB=\E[4%p1%dm' ...
-1
votes
0answers
49 views

What are ways to encrypt a password inside an environment variable [migrated]

I have this file I use to set my username and password before exporting the value. #!/bin/bash echo -n "User:"; read user echo -n "Password:"; read -s password export ...
6
votes
1answer
108 views

Providing normal users(non-root) with initialization and shutdown auto-run capabilities

I'm hosting an experimental/testing Linux box, running Debian Wheezy 7.4.0 distribution. Different users log into the machine over ssh to their accounts and are allowed to run the development tools ...
2
votes
4answers
139 views

Starting a script as another user

I've created a script in /etc/init.d/ which has to run several other scripts from other (non-root privileged) users from their home directories, as if they started them. I launch these scripts ...
0
votes
1answer
38 views

Finding a user's home from bash

I'm trying to get the value of a user's home from a puppet script. This particular user is a Samba user, not a local one, with the username of the form DOMAIN\user. I've tried the following, with no ...
1
vote
3answers
59 views

Batch rename files that end in a dot

I have a large unix fileserver, with a single large SMB share. It serves to Mac, Linux and windows clients. A large portion of the files on this box have been migrated there from a Mac Xserve. One ...
1
vote
1answer
43 views

Get some meaning from apache logs with awk and grep [duplicate]

I am trying to have some meaning from my apache log files: I want to parse my access log and have some statistics about 200 status code hits (how many times each of them was hit). So I tried to learn ...
1
vote
0answers
9 views

SNMPget and bash gives strange results (gauge32 values incorrect)

Reallly strange to me but here is the problem. If I use an SNMP client such as ManageEngineMibBrowser to query the appliance I get what look like reasonable Numbers: dpStatusMemoryStatusUsage.0 97 ...
1
vote
0answers
15 views

Setting tabstop for bash output [migrated]

Is it possible to set a tabstop (number of spaces per tab) for the more and less commands? In vi, I've added this line to .vimrc set tabstop=4 However when I read through a file with more it still ...
0
votes
1answer
36 views

How to set ulimit in chroot with --userspec

I have script to create a minimal chroot (below), but I can't figure out how to get ulimit to work on the chroot'ed process: #!/bin/bash user=$1 apps="$2" cmd_to_run="$3" shift 3 ...
1
vote
0answers
38 views

Using 'find' to email me those files modified recently [migrated]

I'm using 'find' at the end of a script to email me any .log files in the current directory that have been modified in the last 6 hours. I need this because the file names change so I can't be any ...
0
votes
0answers
15 views

Script to apply Simple Finder restrictions to Mac OS X user?

Is it possible to script (e.g. with AppleScript or bash shell script) applying the Simple Finder and an associated application whitelist to a local user account on Mac OS X? We are using Mac OS X ...
-4
votes
1answer
31 views

Killing a bash sh script [closed]

I made an .sh file load.sh which has (almost) unlimited loop of curl requests. I run this as $ bash load.sh. Now it just keeps running the loop. I can't cancel its execution. It keeps running. I ...
0
votes
2answers
33 views

Creating an environment variable for a specific user

When you set an environment variable in linux is it set only for the user who executes it, or can you specify a user when you store it, or instead is it always available for all users?
1
vote
3answers
59 views

Any Linux tool to create a repo file?

SuSE's package manager zypper is able to create repository file in /etc/zypp/repos.d/. zypper -n rr myrepo zypper -n ar -f http://path/to/myrepo myrepo I'm looking for an equivalent tool do the ...
2
votes
0answers
27 views

Symlink all subdirectories in a directory to another directory [migrated]

I'm trying to symlink every directory in a folder to another folder. For example, in the structure below, I need the subfolders symlinked to folder2. - /home/chris/folder1 -- subfolder1 -- subfolder2 ...
3
votes
1answer
33 views

Bandwidth Throttling using tc qdiscs

I am trying to limit the bandwidth between a simple iperf server and client, using a third, passive machine acting as a bridge. With no interference, iperf returns a bandwidth of ~90 Mbits/sec. My ...
0
votes
1answer
28 views

Curl pressing enter or ctr+c in order to have the right response [closed]

This is a script that checks my current ip on this site: http://myip.dnsdynamic.org/ and pick the response and calls an API in order to update my dynamic ip. Here the script: curl --user ...
0
votes
0answers
21 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 i ...
2
votes
1answer
124 views

Bash: two commands in dollar-parenthesis don't have same behavior

I don't undertsand why, in Bash: echo $(hostname --fqdn) works, echo $(id -un) doesn't (id: –un: No such user). Backticks give the same results. Is there some good practice for using this ...
1
vote
1answer
35 views

Bash script for updating multiple servers not accepting RSA keys

In my environment I manage about 10 Linux servers that require regular package updates. I have a script written to connect to each individually and run the update. Additionally, I have RSA keys ...
0
votes
3answers
55 views

Add an additional check (bash script) to the sshd server

Is it possible to run an additional script during the login process of the sshd daemon/server? I would like to run an additional command that uses the IP address and the username of the attempt. If ...
0
votes
1answer
29 views

Riverbed Stringray TrafficManger - API calls for Autoscaling

I am looking for advice on writing a bash script to put new server that we spin-up in AWS and get them added to our Stingrays. We are creating a new environment in AWS that will be muilt-AZ in AWS ...
0
votes
2answers
33 views

Why does this bash command sometimes return a blank string?

I have the following line to generate a random number: head -c 3 /dev/urandom | hexdump | sed -e 's/[0 a-z]//g' | head -c 1 This works fine but sometimes (very few) it returns a new line. Does ...
1
vote
1answer
45 views

Dovecot quota-warning.sh not being excecuted

I would like to run a custom script with dovecot once the user reaches certain percents of their quota. The issue is that no matter what I try dovecot does not seem to execute my bash script. ...
0
votes
1answer
30 views

Sourcing a config file in bash

I know I can source FILE or . FILE a file in Bash, but for some reason I cannot get it to load in the file. I keep seeing "No such file or directory" errors in the console. Here's the directory ...
1
vote
1answer
51 views

What is the Linux command to get the current PPTP ip address?

I have a Linux script that allows me to route some traffic through a VPN interface, and other traffic (from different IP) through another interface. This is my script: echo "ip route del default via ...
0
votes
1answer
40 views

Alias doesn't work in script with #!/usr/bin/env php

I've some PHP scripts which are starting with #!/usr/bin/env php. The default interpreter is PHP 4.4, but the scripts need PHP 5.3, so I created an alias in ~/.bashrc: alias ...
0
votes
1answer
19 views

prepare domain list to work with squid 3.x

the latest version of squid do not accept duplicated domains like: example.com pre.example.com --- this is no longer necessary and it requires domains to start from "." adding dot is simple: ...
1
vote
1answer
56 views

Start Unix screen, Run command, Detach

How can screen be used to start a new session and run a command within that session without killing that session? screen -S myScreenName runSomething I tried the above command and it says [screen ...
0
votes
1answer
42 views

install mdadm without user input in wheezy

I am switching to debian from ubuntu and setting up RAID0 on my AWS boxes using user-data. Things were working fine on ubuntu but on wheezy apt-get -y install mdadm --no-install-recommends throws ...
1
vote
0answers
43 views

Ssh issues on Google Compute Engine

I've just updated a few servers to the newer version of the gce stack, and I've started having some ssh issues that I'm not quite sure how to fix. I've already looked into issues with the firewall, ...
0
votes
0answers
20 views

echo or copy file using distributed shell aka dsh

I'd like to copy a text file using distributed shell (aka dsh), but I'm having some trouble getting that done. I could just copy it like a normal file, but I don't want to because I'm trying to create ...
0
votes
1answer
48 views

Can a user be excluded from /etc/profile.d scripts?

I am having a problem using Rsync/SSH with a specific user for Amanda backups on a server. rsync -e 'ssh -i /var/lib/amanda/.ssh/id_rsa_amdump' -az otherserver:/dir/to/copy /copy/dir I have noticed ...
1
vote
1answer
25 views

“s” character not working on command prompt after bash history completion

Im using Centos 6.3 and have customised my .bash_profile with the following commands to help with history completion (and colorising the prompt): bind '"\e[A": history-search-backward' bind '"\e[B": ...
0
votes
1answer
39 views

How to find full process arguments and associated listening ports?

I can execute netstat -atulpn | grep java to find all Java processes with their accompanying ports, which is great, however I would like to also have the processes full execution arguments also shown. ...