Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).
0
votes
0answers
41 views
Bash scripting rsync puzzler [migrated]
Frustrating. The script below work for the first two targets, but not the second.
#!bin/bash
...
backitup () {
Todaysdate=`date "+%Y-%m-%dT%H_%M_%S"`
Sourcedir=$1
Destination=$2
Username=$(echo ...
2
votes
2answers
35 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
1answer
67 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 ...
0
votes
0answers
18 views
schroot auto-mounting doesnt works?
I've been reading about schroot and trying to understand the parts in various tutorials that mention about auto mounting. For example check the section (and the parts after it) "Basic schroot ...
-1
votes
0answers
8 views
Execute command with Jailkit
So I created a jail at /opt/jail using http://olivier.sessink.nl/jailkit/ - how can I execute a command inside the jail now and get the output as I can do with chroot ?
The simplest command I'd like ...
-2
votes
0answers
15 views
HP Project Portfolio Manager [closed]
Having an odd issue deploying certain files using HP PPM (I'm new to this tool and do not have admin rights to the relevant machines so the information I have is limited to what I'm including).
...
0
votes
0answers
33 views
BASH: launch background process and check when it ends [migrated]
How can I launch a process in background and check when it ends within a bash script?
My idea is a script like this:
launch backgroundprocess &
while [ Process is running ];do
echo "PROCESS ...
2
votes
1answer
34 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
23 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
88 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
29 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
55 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
21 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
43 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
126 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 [email protected] 'curl http://some_server/script.sh | bash'
This is really clean and handy to execute scripts remotely, however, I don't ...
0
votes
4answers
132 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
35 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
38 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
38 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
58 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
29 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
36 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
16 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
47 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
27 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
34 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
46 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
74 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
38 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
28 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
32 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
53 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
59 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
37 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
47 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
63 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
37 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
42 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
79 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
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
106 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
44 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
58 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
...