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

learn more… | top users | synonyms (1)

3
votes
2answers
198 views

How do I properly escape and interpolate variables in Bash?

I'm trying to write a one-liner to convert html entities present in some files (all html with UTF-8 encoding) I've tried recode HTML_4.0 file.htm but that also converts non-ASCII characters (it ...
1
vote
2answers
99 views

Close/Quit All Screens with SSH

I have a lot of screens on my server. With screen -ls I get: There are screens on: 12858.test1 (Detached) 28210.test2 (Detached) 12494.moretesting3 (Detached) 31787.testingfour4 ...
2
votes
1answer
335 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
121 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 ...
2
votes
1answer
914 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
63 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
58 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, ...
3
votes
1answer
448 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
602 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 ...
-3
votes
1answer
81 views

How to update bash 3.1.x to 3.2.x? [closed]

# 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
434 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 ...
1
vote
5answers
2k 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
330 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
91 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 ...
1
vote
1answer
279 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
92 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
200 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
107 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
52 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
194 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
52 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 ...
0
votes
1answer
214 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
80 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
216 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 ...
1
vote
1answer
372 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
826 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
251 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
1answer
45 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
1answer
61 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 ...
2
votes
2answers
111 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
66 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
87 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
3answers
280 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
89 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
250 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
172 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/^.* ...
-1
votes
1answer
105 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
1
vote
2answers
2k 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
316 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
80 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
315 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
48 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
55 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
325 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
199 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
68 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 ...
1
vote
1answer
110 views

Linux date translation to different time zone

The Linux server is hosted in EST timezone. But I want to translate the output of date command to IST(Indian Standard time +5:30 hrs) format and use it in a shell script. Is there any option available ...
0
votes
2answers
496 views

Executing a remote MySQL query over SSH

I am trying to execute a MySQL query over ssh using the following command: ssh -p 2020 mysql@mysql1.local.mydomain.com "mysql --verbose --compress --secure-auth --database ops --execute \ 'INSERT ...
0
votes
1answer
56 views

Allow user to run script as root, but not the individual commands within the script

I don't have much experience with this type of task and realize I need to get more familiar with the sudoers file. I want a user to be able to connect via ssh and run a script that performs a bunch ...
0
votes
1answer
109 views

Deleting Files in a Zip Archive on Linux

I have a situation where I need to be able to run a script and delete specific files within a zip archive. Below is the general setup /mnt/directory /mnt/directory/Folder1 ...