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

learn more… | top users | synonyms (1)

1
vote
1answer
57 views

Wrangling sed to find and reformat login date (or, how to kill idle mosh-server processes)

I have an old method of killing idle mosh-server processes, which doesn't work on my new VPS. Here's the old method, which I run in root's crontab to clean up mosh processes that have been idle for ...
-1
votes
2answers
54 views

What user is the script run as after Carbon Copy Cloner ends scheduled task?

On Mac OS X I keep data on a local server mirrored with the same data on a remote server with a scheduled backup task done with Carbon Copy Cloner. After the backup is done a bash script is run as ...
0
votes
1answer
124 views

Replace an IP address with it's whois using bash

I have a traffic log similar to this "page visited" for xxx.xxx.xxx.xxx at 2013-10-30 and I would like to replace the ip address with the result of it's whois lookup. I can export the ip addresses ...
0
votes
1answer
139 views

Is it possible to auto update php.ini via a bash script? [closed]

I'm trying to write an install script and i need to change the sendmail line in php.ini but I want to do this automatically at the moment I'm doing this manually: sudo nano ...
0
votes
1answer
45 views

Netcat: connection lost before transfer is complete

Interesting thing with Netcat (nc) in CentOS 5 or 6 (nc-1.84-10.fc6 or nc-1.84-22.el6.x86_64). How can I work it around? I can't find a bug about this, but It models a file transfer to a remote ...
3
votes
1answer
133 views

How to detect if mount point exists from init.d script?

After a reboot, I'm executing an application from a mounted network share (autofs) using an init.d script. The script starts by waiting 30 seconds before attempting to execute the command, in order to ...
1
vote
2answers
62 views

Long string insertion with sed

I am trying to use this expression to insert the contents of one text file into another after a give string. This is a simple bash script: TEXT=`cat file1.txt` sed -i "/teststring/a \ ...
0
votes
2answers
51 views

Bash -x to file and email

I have a script that issues a lot of commands. I wish to save the output of this script (Errors and stdout) to a file, but I also want the actual commands that were executed to be saved to the file as ...
0
votes
2answers
42 views

Change/Deactivate the shell for an amount of users on SUSE Enterprise Server

I have a SUSE Server to which ~300 users are connecting. About 100 of them have to be deactivated. I think it would be nice to change their shell to /bin/false either with chsh or with usermod. ...
-1
votes
1answer
30 views

Bash syntax, square brackets and -d option

I have this command in bash: [ -d node_modules/phantomjs ] || npm install -g phantomjs I am not sure what it means in plain English... Can anyone please advise?
1
vote
0answers
74 views

grep is inconsistently defaulting to grep -P?

I have a script that does some housekeeping that works perfectly well when invoked from an interactive shell, but did nothing when invoked by cron. To troubleshoot this I started a shell with a ...
0
votes
1answer
77 views

How can I measure the cumulative network usage of a process, from execution beginning to end

I want to measure how much bandwidth git pull uses, preferably by prefixing git command with desired program, i.e. nettally git pull Alternatively, is there some sneaky way to accumulate nethogs / ...
1
vote
3answers
58 views

Override path to binary for particular user

My question seems to be trivial but I didn't manage to find anything helpful in internet. I have a binary in /urs/bin/binary but it is outdated and newer version is available on some mount for ...
2
votes
1answer
71 views

possible /how to obtain the return code for a command executed before the last command?

Linux bash (or other shell.) Have you ever fat fingered "echo $?" into something like "echo $4" thereby permanently preventing you from knowing the return code for the previous command? I do this ...
0
votes
2answers
169 views

Running ssh-agent from a shell script

I'm trying to create a shell script that, among other things, starts up ssh-agent and adds a private key to the agent. Example: #!/bin/bash # ... ssh-agent $SHELL ssh-add /path/to/key # ... The ...
0
votes
4answers
64 views

How can I make ls and xargs combined omit path

I have a folder called lib. In that folder are some files. I want to obtain all the names of the files that end in .jar, and concatenate them into a line, separated by spaces. I don't want the path ...
-1
votes
1answer
37 views

specify multiple filenames in one line. bash

guys. im trying to add to logrotate files from a some directory. it should be either *.txt files or *_log files. wtat's the right syntax for this: /var/www/html/groupware/horde_logs/[*.txt|*_log]{ ...
-10
votes
1answer
77 views

Stop server maintenance [closed]

I am ssh'ing into the remote CentOS server with Bash. I was trying to stop port 8080 and so I typed stop 8080 with "root" privileges. Now, the server is scheduled for maintenance in 8080 minutes as ...
-1
votes
2answers
100 views

how I can get the value of JAVA_HOME from my client

I have nagios client and server, how I can get the value of JAVA_HOME from my client? I have use to set shell command in script that is running from remote host: echo $JAVA_HOME and printenv | grep ...
0
votes
1answer
52 views

Unable to get cron to append output from wget

I have a cronjob setup and running, but the logfile keeps getting overwritten every time it runs. I would like for the wget output to be appended each time the cron runs. Why is this and how do I fix ...
1
vote
1answer
76 views

Change PS1 value for all Bash users

I am trying to change the prompt value for all users of a system (the $PS1 variable) to the same value. I have the following stored in file /etc/ps1: PS1='` if [ $? -eq 0 ]; then echo -n ...
-1
votes
2answers
52 views

Way to aggregate large influxes of email [closed]

we are setting up a monitoring solution that'll utilize email notifications. However we have already seen that there are instances in which certain problems will affect large clusters of nodes ...
0
votes
4answers
410 views

How to make bash script executable for a user, but not readable

I'm trying to run a script at login that will execute for a regular user, but not be readable by that or other non-root users. I've tried various things including chmod/chown combinations, as well as ...
1
vote
2answers
137 views

How can I make ssh wait until the command exits? [closed]

I have a script that looks like this: SERVER="RHT372 RHTl373 RHT374 RHTl375" case $1 in "stop") for SERVER in $SERVER do echo "================================================" echo ...
0
votes
0answers
33 views

Include executed cron command when outputting to log

Is there a way I can include the command in the output when I'm logging to a file? For example * * * * * date && /path/to/php /path/to/script.php >> cron.log 2>&1 Would give ...
0
votes
2answers
50 views

Copy files from path to path same structure for each user

How to copy files from source /backup/cpbackup/daily/a1/public_html/index.html /backup/cpbackup/daily/b2/public_html/index.html /backup/cpbackup/daily/c3/public_html/index.html ...
2
votes
1answer
82 views

script migration from CentOs to Debian - error message “[: 10: -lt: unexpected operator”

As I was trying to execute a script in a new environment, I came up with this error: [: 10: -lt: unexpected operator Here is the painful part of the script: end=$((SECONDS+60)) while [ $SECONDS ...
-1
votes
3answers
73 views

How to replace a certain path from the PATH variable? [closed]

I am using Cygwin and would like to modify the following PATH via bash shell: /usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VSTSDB/Deploy:/cygdrive/c/Program ...
1
vote
0answers
224 views

Can't write to other users “you have write permission turned off”

For some reason I'm not able to write to other users on my system. [root@hostname ~]# write write: you have write permission turned off. [root@hostname ~]# mesg y [root@hostname ~]# mesg is y ...
-1
votes
2answers
99 views

Monitor port status in Linux [closed]

I want to monitor the list of used ports in linux system. I want to make a script that can run an alert when a new port is up or down. For example when the port 8080 is up , i get an alert: this port ...
0
votes
2answers
95 views

What seems wrong with this bash script? [closed]

I found an initscript that for some reason insists on starting the specified application as the root user. I can't wrap my head around why it is doing this, any hints? The script runs on Redhat ...
0
votes
1answer
33 views

Is there a tool for indexing a directory in order to perform cheap content search? (hashing by word, for example)

I am often using grep -R on an entire directory tree to find all files that contains a specified word. I wonder if there is a tool that makes the whole operation much faster, maybe via hashing? (Unix ...
0
votes
0answers
37 views

How can I detect if I have access for resource?

I'm trying to write bash script for file copying from local machine to FTP using lftp. Problem is, when someone enter inaccessible path for mkdir or put, then LFTP returns e.g.: Access failed: 550 ...
0
votes
0answers
22 views

Restarting Multiple Processes Running Via Screen If Any Are Using Abnormal CPU Resources

I'm running 4 CS 1.6 servers in 4 different screens, so I have 4 processes by the name of "hlds_run" with different process ids. Due to Valve being all-around terrible at porting their server code to ...
1
vote
3answers
68 views

Dynamic logic in environment variable?

I regularly invoke a particular remote server from a (Linux/bash) command line via tools like cURL or wget. This server requires an authentication token that expires every 10 minutes. I have a program ...
0
votes
1answer
69 views

nohup create multiple process

I am using nohup for the script run inotify command, because inotify stop when I exit from terminal so I want the script to run on background. so I run the script like this nohup /path/to/script.sh ...
11
votes
1answer
276 views

Can Bash Tell Me Which SSH Public Key Was Used To Authenticate?

Let's say I want to track my root users. Each of them has a unique private key and their public keys have been stored in /root/.ssh/authorized_keys. Given that each user logs in with their unique key ...
2
votes
1answer
159 views

What is the format of mtr raw output?

I use mtr to count number of hops to a host and pass that number to a script. I discovered -l (or --raw) option which produces an output ready for parsing. However, I'd like to know where to find this ...
0
votes
2answers
37 views

Getting the executed source from bash

Okay, this is a last attempt to see if I can salvage something I accidentally did. I accidentally did "command > ~/.profile" instead of "command >> ~/.profile" on my computer. I didn't have it ...
0
votes
2answers
67 views

Strange characters from output in shell

Over the past few years there have been some Linux systems that will output strange characters when running various commands. Here's an example of my output from the sensors command on one of those ...
0
votes
3answers
146 views

Running svnsync on a repository with group suid/sgid set fails to execute a hook

I have a Linux server that I am attempting to run svnsync against a list of repositories to mirror / back up. I created a folder /srv/backups and set it to have the group gsid of adm, using chmod g+s ...
0
votes
0answers
37 views

use socat to provide password to bsign

I have many servers, where I deploy various binaries. For this purpose I use a script that packs them into archives, publishes in the local repository and then ssh-es to the target servers and ...
0
votes
1answer
161 views

cron.hourly script executing multiple times

The setup I have a script /etc/cron.hourly/msm-hourly that contains this: #!/bin/sh LOGPATH='/opt/msm/servers/cronscripts' LOGFILE="$LOGPATH/msm-start.log" # Make restart dead servers echo "" ...
1
vote
0answers
59 views

error in killing tshark from shell script

I'm getting this error "* glibc detected * /usr/sbin/tshark: double free or corruption " while doing this, any idea why? #!/bin/bash trap 'my_exit; exit' SIGINT SIGQUIT count=0 /usr/sbin/tshark -i ...
0
votes
0answers
117 views

expect: how to use expect scripts from within a bash subroutine

I want to write a login script in expect. But I want this to be reused in different other scripts. I want to make all the login commands part of a bash subroutine. ie instead of expect_login.sh ...
0
votes
1answer
557 views

Limit tcpdump capture files by time and size

I am having some problems getting tcpdump to log all internet traffic on an interface with the following limitations: I would like a new pcap file every hour with time and date tag in the name If ...
0
votes
2answers
45 views

Automatic VM disk resize

I got a KVM/Qemu setup that works great. Now I want to streamline the provisioning of new VMs. The two obvious ways are to either clone an existing disk or install from scratch (with an automated ...
1
vote
3answers
151 views

How to remove a file where the file name has character issue

I want to remove a file from a server via bash rm command. This is a sample file Test_ Mürz.jgp. How would one go about removeing files with such chars issues in the filename on a grand scale ... ...
0
votes
1answer
72 views

Git installation for a newer version fails on ./configure

I'm trying to upgrade my Git version to 1.8.3 on my fresh new CentOS 6.4 server(Cloud). I'm trying these instructions here because I will then install the Gitlab. I have used this document before ...
3
votes
2answers
55 views

Preventing bash tab completion of an environment variable with a FS path value from removing the environment variable name

Friends, I am using GNU bash as my shell on Linux: $ bash --version GNU bash, version 4.2.45(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU ...