Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).
1
vote
1answer
27 views
rsync certain files, excluding the rest, ignoring .svn/ directory, recursively
I'm using rsync to copy some files from a share to another.
Recursively, I need to:
Delete files at destination that were removed from the origin
Only sync php and js files
Exclude every other file ...
-1
votes
1answer
21 views
Determine which process owns an flock'ed file
I have a Bash script that runs in multiple processess concurrently. The relevant portion looks like this:
flock /var/lock/my_lock my_command
Given that /var/lock/my_lock exists, is there a way to ...
0
votes
1answer
81 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 ...
1
vote
2answers
28 views
How to “unlocalize” bash script output
I have a problem with localized bash output. Say, I have to run some script on two different machines and then compare its output. It could of be done with grep easily, but one of the machines is ...
0
votes
2answers
45 views
Bash files with Github [closed]
I've never saved any of my bash scripts with an extension and I've just recently pushed a bash script to Github and realized that it's not properly highlighting the correct syntax such as: comments, ...
2
votes
1answer
49 views
How to detect, in the guest operating system, if the vmware tools are out of date?
I'm trying to find a generic way of checking, in the guest operating system of a virtual machine, if the VMware Tools are out of date.
The best way I have found so far has been to check the output of ...
2
votes
1answer
17 views
Standard place for user defined bash_completion.d scripts?
I have user access (no root) into a Linux (Suse) machine where I developed some bash scripts and the corresponding bash autocompletion rules.
Since the scripts belong only to my user and therefore I ...
0
votes
0answers
27 views
How to update bash 3.1.x to 3.2.x on CentOS?
# bash --version
GNU bash, version 3.1.17(1)-release (i686-redhat-linux-gnu)
# yum install bash
Failed to set locale, defaulting to C
Loading "installonlyn" plugin
Setting up Install Process
Setting ...
4
votes
2answers
103 views
rsync not removing single quotes around array of strings --filter list
Trying to safely retrieve files from heavily infected Windows XP and 2003 machines that came to us from an acquisition. I have a similar need for automating a script that would run on PXE booted ...
0
votes
5answers
79 views
Executing script remotely with “curl | bash” feedback
I'm working on a platform that uses a lot such commands:
ssh login@server.com 'curl http://some_server/script.sh | bash'
This is really clean and handy to execute scripts remotely, however, I don't ...
0
votes
4answers
124 views
Script runs on 50 servers. How can I ensure only one executes a particular step?
I have some work that needs to be done on 50+ servers. The first step is to checkout an updated version of some source code onto a shared directory (assume all have the shared drive mounted). The ...
0
votes
1answer
34 views
Close a SSH Session when it suspend
I start a ssh session on a remote host and execute a script on the remote host. The Script is an update script that change the remote IP.
Now my local bash script hanging on the line with this ...
0
votes
1answer
37 views
How do I pass a multiline variable as a parameter to a function
Trying to capture and display the output of curl was driving me nuts. I finally found a workaround, but I don't understand why it is needed.
Here's a script that fails:
#!/bin/bash
function ...
1
vote
1answer
34 views
Multiple spaces in folders and files for rsync backup via /bin/bash /bin/sh
Need a one-time backup of two old messy Windows XP machines because of a company split. Using CentOS 6 x64 minimal install, i mounted some MS Windows NTFS harddrives installed locally via ntfs3g and ...
1
vote
3answers
56 views
How to stop bare bash cd (change directory command) from changing the working directory to $HOME?
I do this too often:
$ pwd
/a/long/long/way/from/anywhere
$ cd # oops - meant to tab-complete something
/home/$USER
Can cd defaulting to $HOME be disabled?
1
vote
1answer
26 views
Remote rename of a file on Samba share via Bash script
I'm running a Bash script under Cygwin, but this question applies more broadly.
I have a remote file: //someremoteserver/somefile.db
That "//" path is under Cygwin--it's essentially a UNC pathname ...
0
votes
1answer
30 views
Get logged on user in init.d script
I have created an init.d script to control a process as a service, in RHEL 6.x. In the script, I am using /sbin/runuser to start the process as an unprivileged user. This part of the script is working ...
0
votes
1answer
34 views
expect script works fine standalone not from bash script
I am running a expect script,which login to a server check if iptables running and return the log file of the status. There is a hostfile also given with server list and password, expect is being ...
1
vote
2answers
34 views
Need help rescuing a RH virtual server - shell command to fix mistake?
I have a VM which runs one of our primary applications. Prior to making a rather heavy handed change, I made two lines of backup. First, I took a VM snapshot. Second, I ran a recursive sed command ...
-2
votes
1answer
15 views
Zip with a parent folder [closed]
I am currently in a folder /tmp/foo, e.g.
/tmp/foo
/tmp/foo/a
/tmp/foo/b
and I want to zip all the files/directories under this folder with a virtual folder bar, so that when un-zipped, it will be ...
0
votes
1answer
43 views
Monitor tomcat logs for exception
I am planning to write a bash script and run it as a daemon in the background. The script will continuously monitor the tomcat server logs for any exception, error, etc.
When an exception occurs, it ...
1
vote
2answers
28 views
set — $(cat /proc/loadavg)
Hi I have a munin plugin that does this
load_fetch() {
set -- $(cat /proc/loadavg)
cat <<EOF ...
0
votes
1answer
24 views
screen, expect and scripted detached interaction
Trying to write a bash script which will open a screen, start a python application, and interact with the python interaction as required when it is first started.
If not possible in screen, I would ...
0
votes
0answers
22 views
Watch goes blank on refresh [migrated]
I'm running the following command in watch. Works for the first one but subsequent ones go blank
watch diff <(pacman -Q) <(ssh kate "pacman -Q")
1
vote
1answer
32 views
How to not run /etc/profile.d/custom.sh during Secure FTP login
When I attempt to Secure FTP (using WinSCP) to my CentOS 6.4 box I'm prompted with a message that states:
Received too large (168438314 B) SFTP packet. Max supported packet size is 1024000 B.
This ...
1
vote
2answers
44 views
how to execute bash script with crontab in centos? [duplicate]
My bash file is not executed by cronjob created as root. The cronjob setup looks as it follows
0 0 * * * mysql_backup.sh
does need to be decalared with the bash command 0 0 * * * bash ...
0
votes
2answers
73 views
Putting this command into bash script
with help of google , script that measures multicast streams bandwidth.
Here it is
tcpdump -tnn -i eth1 -f multicast | sort | uniq -c | awk '{print $3,"> "$5,$1*$NF/2*8/1024 " Kbps"}' | awk '$1 ...
0
votes
0answers
37 views
Colorize Bash Console Color [migrated]
I need to be able to set my CentOS 6.4 bash prompt color to yellow.
I've managed to find where to set this (.bashrc) and the ANSI color for yellow (\e[0;33m).
I've setup my prompt as follows:
...
0
votes
1answer
27 views
Nagios Check - Scripting
If I hard code the process I want to find and run script a
Script A
#!/bin/bash
PROCESS=/System/Library/Frameworks/QuickLook.framework/Resources/quicklookd.app/Co
number=$(ps aux | grep $PROCESS | ...
0
votes
0answers
31 views
Very strange behavior with grep and IFS [migrated]
I'm having trouble using grep, the returned results are "n-empty", I mean without the 'n' character...
This is the script sample :
OLDIFS=$IFS
IFS="\\n"
i=$(grep -ril $1 *)
echo $i
IFS=$OLDIFS
...
0
votes
1answer
52 views
How to write a script to install multiple things by just executing it
I have a server (centOS) on which I would like to install the staple development tools. Java, Tomcat, and MySql.
What is a good way to write a script that can be ran on newly spawned server so that ...
0
votes
0answers
32 views
How to turn off the beep only in bash tab-complete [migrated]
I find the beep useful for some things, so I only want to turn it off for tab completion (I'm not asking how to completely turn it off, that has already been answered). I also don't have root access, ...
2
votes
2answers
55 views
Can I use IPs assigned to virtual network interfaces in a bash script?
I'm wondering if it's possible to dynamically read in the IP addresses of network interfaces for use in a bash script. Something like:
#!/bin/bash
MYPUBLICIP= get_eth0_address
MYPRIVATEIP= ...
0
votes
2answers
36 views
Copy file to backup directory preserving folder structure
I have to copy a file in a directory, to its backup directory, preserving the folder structure.
Ex. The file aaa in MyFolder/Test/aaa to .MyFolder.bck/Test/aaa
I tried to use
cp --parents ...
3
votes
2answers
46 views
Get hostnames into ssh tab-completion (with minimal editing)
I know I could get a list of hostnames into bash tab-completion of ssh by adding them to /etc/hosts, but since they are on DHCP, it's kinda bad practice.
Does anyone know another DHCP-aware way, that ...
0
votes
2answers
59 views
tail-pipe-awk script, fine on Centos but weird on Ubuntu
I wrote a script on CentOS and now I'm trying to run it on Ubuntu and it is behaving unexpectedly. Here's something like the script, which I run under bash:
sudo tail -F ...
0
votes
1answer
36 views
Pipe tail output via elinks
Consider the following command:
elinks -dump file.html
It will print the file, formatted as plain text (without HTML tags).
The file.html is constantly updated (a new data is appended) and I want ...
0
votes
1answer
39 views
Review of a crontab script to add timestamps to minutely runs; any suggestions?
I've got a crontab job set to run minutely as such:
* * * * * /home/username/public_html/domain.tld/production/scripts/cron_runner.sh
My goal is to add some timestamps to output from cron so I can ...
0
votes
1answer
72 views
> /dev/tty - What is the purpose of this command?
This is in one of the rc scripts in Red Hat and I want to understand the purpose of > /dev/tty[n]
last=0
for i in `LC_ALL=C grep '^[0-9].*respawn:/sbin/mingetty' /etc/inittab | sed 's/^.* ...
2
votes
0answers
40 views
Specify script to run with SSH at same time as login [migrated]
I would like to know if there is a way to specify what script to run (on the remote machine) at login. I'm logging into a Debian box with key-pair authentiation (no password needed). The script ...
-1
votes
1answer
30 views
Can not seem to get expr substr to work
Can anyone tell me what I am doing wrong ?
[ /jlr/sub/libexec/vmr-staging ] $ expr substr "onetwothree" 1 4
expr: syntax error
I got the syntax from http://stackoverflow.com/a/220464/1150847
0
votes
2answers
88 views
chsh: PAM authentication failed
i want to change default shell env
and run chsh -s /bin/zsh as root user,
but a error message appeared: chsh: PAM authentication failed.
i find this thread ...
0
votes
1answer
43 views
Error when using Chef on OS X: “bash: chef-solo: command not found”
I have chef installed on my local machine: Mac OS X 10.8.3
I also have chef installed on a remote server: Ubuntu 12.10 x64 Server
On the local machine, when I try to execute a command using ssh ...
0
votes
0answers
22 views
Installing keys with .DEB packages silently fails
I'm trying to create a .DEB package which will install a number of certificates and keys onto a system.
To do this, i've gone through the standard package creation process, and thrown two files, ...
1
vote
2answers
55 views
bash: use outside variables when reading multiple lines into ssh
I apologize if the title doesn't quite describe what I'm looking for. Please edit if possible.
I have a bash script that does the following:
serveruser="root"
serverip=1.2.3.4
...
1
vote
2answers
33 views
I want to filter out two lines from the output of a program [closed]
I have a command that outputs a bunch of data, but I only want two lines. Grep doesn't work because the lines I want are not next to one another. I can't seem to figure out sed...
Help please. :)
...
-1
votes
1answer
33 views
Trimming characters of a command in bash
I am running command in a bash shell as follows:
/usr/bin/ntlm_auth --request-nt-key --domain=TEST.DOMAIN --username=Administrator --password=mypassword
Although I would like to trim the last 6 ...
2
votes
2answers
59 views
How do i use the {} operator in find execution inside exec
I tried this bash command:
find /var/www/ -path '*wp-admin/index.php' -exec mv {} $(dirname {})/index_disabled
But the second {} is not executed.
It results in just ./index_disabled instead.
How ...
0
votes
1answer
68 views
How do I rename all files index.php containing a certain folder in the path?
I want to rename all wordpress admin index files into index_disabled in the folder
/var/www/
I need a script like
find /var/www/ -path '*wp-admin/index.php' -exec mv {} $(dirname ...
0
votes
0answers
32 views
How can I block all wordpress admin access on a server?
I administer a server with lot of wordpress installations.
Is there a way to block all admin-accounts with one script, or to add an extra password in the global apache configuration?
I would like to ...


