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

learn more… | top users | synonyms (1)

8
votes
7answers
453 views

Find directories, where files with a specific ending are missing

I want to display all directories, that do not contain files with a specific file ending. Therefore I tried using the following code: find . -type d \! -exec test -e '{}/*.ENDING' \; -print In this ...
0
votes
1answer
965 views

Improper output in SSH session on OSX using FreeSSHd on Windows with cygwin bash/sh shell

I am testing out running an SSH server on a local Windows VM. I have installed FreeSSHd and set the command shell to "c:\cygwin\bin\sh --login -i" (bash as well) with "Use new console engine" ...
0
votes
0answers
34 views

Script to restart service fails for most of the time

I have created a script that restarts a FTP service (a java program) if this value of below command is not zero: find /home/files_to_send -name "*.pdf" -cmin +10 | wc -l My problem is that while ...
1
vote
3answers
6k views

How to get netbios name from network computer? (Linux)

I want to scan my network periodically and get the Ip, mac, OS and netbios name. So far I got everything done with a bashscript that runs nmap, but the netbiosname is still a problem.
-1
votes
1answer
28 views

Why does ssh -f create multiple processes when a pipe is used? [closed]

When I on my Linux host do ssh -f 10.10.47.47 "/opt/omni/bin/mbuffer -4 -v 0 -q -I 8024 | /usr/sbin/zfs receive tank/test" then I see on the remote host 27349 ? S 0:00 bash -c ...
1
vote
2answers
2k views

Rsync Exit Code Checker - Bash

I have a simple script on my home server to sync data to my backup drive to be stored. Right now it runs multiple rsyncs one after another. Sometimes rsync fails on one or two of them. When this ...
-1
votes
1answer
28 views

Bash shell copy files on the hidden directory [closed]

Need help with Unix script. how do you use /bin/cp to copy files from /somepath/somedir/somewhere/.temp_folder to /somepath/somedir/somewhere/ my line /bin/cp -r somepath/somedir/somewhere/.[!.]* ...
3
votes
2answers
669 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 ...
2
votes
10answers
10k views

bash code in rc.local not executing after bootup

Does anyone know why a system would not execute the script code within rc.local on bootup? I have a post configuration bash script that I want to run after the initial install of VMware ESX (Red ...
13
votes
4answers
34k views

How do I sleep for a millisecond in bash or ksh

sleep is a very popular command and we can start sleep from 1 second: # wait one second please sleep 1 but what the alternative if I need to wait only 0.1 second or between 0.1 to 1 second ? ...
0
votes
0answers
26 views

name of script within a init script

I'm trying to figure this out. i have /etc/init.d/startup inside the startup script I'm doing a few things: (or i will like to do) creating a PID file that should look like: /var/run/startup.pid ...
1
vote
1answer
112 views

Different bash path variables when using ssh script vs interactive ssh [closed]

I'm trying to run some ruby (bundler/rvm) commands via a script using Plink. I noticed that it was complaining about not knowing where some commands were. It seems as though my $PATH variable ...
3
votes
2answers
4k views

How to keep: daily backups for a week, weekly for a month, monthly for a year, and yearly after that

I need to backup data and config files on this server, daily. I need to keep: daily backups for a week weekly backups for a month monthly backups for a year yearly backups after that All of this ...
0
votes
1answer
62 views

Execute a service as a specific user under ubuntu

I'm running a gameserver and want to start it on a screen on system start, but screen is user specific, so I have to run the command as 'user'. So I wrote this short service script which starts itself ...
0
votes
0answers
47 views

Barnyard2 error on start

Been setting up a snort box with barnyard2, run into the error below. Can someone please help? $Starting Snort Output Processor (barnyard2): ./barnyard2: 35: ./barnyard2: barnyard2: not found ...
-1
votes
1answer
125 views

Bash Script - Expect does not send password that ends with $!. Also need improvement to report connection timed out

Update: Password issue is fixed and connection timed out message was fixed too. Adding \ before $! worked. Example: *password\$! set passwds { *password\$! @tempP@ss %Test4%} For connection timed ...
-1
votes
2answers
32 views

set bash alias from bash script (not command line)

Differently from bash shell (for create new alias): alias test="echo test" if I do the same thing using a bash script, alias does not run: #!/bin/bash alias test="echo test" also export it, same ...
3
votes
3answers
58 views

How to pass command output as several arguments to another command

I have a command that produce a output like this: $./command1 word1 word2 word3 I want to pass this three words as arguments to another command like this: $ command2 word1 word2 word3 How to pass ...
0
votes
0answers
37 views

What is a safe alternative to wildcards in /etc/sudoers?

In the /etc/sudoers file on my Red Hat server, I have this line: %webdevgroup ALL=NOPASSWD: /bin/chmod * /home/http/* This is clearly a bad idea, since someone could do something like this: sudo ...
2
votes
5answers
10k views

ssh to multiple hosts and sudo multiple commands

I need to loop through and ssh to multiple hosts and run a series of commands on each. something like: for i in $(jot -w '%02.0f' 14 1) >do ssh user@host$i sudo -i "command1; command2; command3" ...
17
votes
6answers
8k views

Log all commands run by admins on production servers

It is company policy for admins to login to the servers via a personal username, and then run sudo -i to become root. Upon running sudo -i, sudo will create an environmental variable called ...
1
vote
2answers
330 views

Expect script error send: Spawn id exp4 not open while executing

Update: Working code added here for others CREDITS to : http://serverfault.com/users/30957/glenn-jackman @Glenn I'm sorry! just apologizing and I mean it! Sorry Glenn your code need few changes ...
91
votes
24answers
28k views

How do I prevent accidental rm -rf /*?

I just ran rm -rf /* accidentally, but I meant rm -rf ./* (notice the star after the slash). alias rm='rm -i' and --preserve-root by default didn't save me, so are there any automatic safeguards for ...
0
votes
1answer
47 views

Mass disable customers in OTRS

The problem is about OTRS customers. I can't use an external customer backend, so I want to update the customer DB via CSV files. I already wrote a script to add new Customers via ...
0
votes
1answer
27 views

Send email on ldap creation

I have an LDAP server setup on a server running Debian 7 and I wanted to make it send out an email whenever a new user was created on that LDAP. I thought a cronjob would be best, but I have no idea ...
1
vote
5answers
2k views

Make ls print it all on one line (like in terminal)

ls prints differently depending on whether the output is to a terminal or to something else. e.g.: $ ls . file1 file2 $ ls . | head file1 file2 Is there some way to make ls print out on one line ...
1
vote
1answer
75 views

How to grep a continuous stream, with paging

I posted this to Superuser but got no takers: http://superuser.com/questions/832578/how-to-grep-a-continuous-stream-with-paging I want to take a log file and filter out some irrelevant log entries, ...
0
votes
3answers
42 views

Modify config file settings from bash [closed]

I need to modify a config file from a bash script, changing the values of particular settings. I need to make the change using common Linux tools (sed/awk/tr/etc.). The config file can have ...
0
votes
1answer
31 views

How to check the existence of multiple directories?

I have a script which obviously faulty: if [ -d "$BACKUP/${DATE_MAX}_"* ] then ... fi This script would only work if there is a single or no directory there at all. If there are multiple ...
2
votes
1answer
70 views

Apache - add http headers to requests, using script (bash, perl, php etc) to set the headers

I trying to work out the feasibility of a project where I want to be able to have a script run on every request (preferably filtered by mime type), and a script run to set the headers for the ...
0
votes
1answer
48 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 ...
1
vote
1answer
70 views

Why deployment sh script don't fails on failed nginx reloading?

I have sh script that restart nginx like the following: #!/bin/sh -e set -e error_exit() { d=$(date '+%D %T :: ') echo "$d Error: $*" >&2 exit 1 } if ! sudo service nginx ...
3
votes
2answers
505 views

Is there a way to make objdump read from stdin instead of file?

In my specific case ,I want to use it to dump what I echo. I don't want to involve any file... Is there a way to make objdump read from stdin instead?
0
votes
1answer
35 views

Script that checks and runs a jar, sometimes runs it twice.

I jave written a small bash script to run every 10 minutes, check if a certain program is running and if not run it. However, I noticed that sometimes I have two instances of the same program running ...
67
votes
6answers
45k views

How to test if my server is vulnerable to the ShellShock bug?

How can I ensure my Bash installation is not vulnerable to the ShellShock bug anymore after the updates?
0
votes
1answer
37 views

Script to copy auth keys to remote servers needs password four times

I work on multiple servers through ssh. I have automated the copying of ssh auth keys with the script below. The only problem is it asks for the remote servers password 4 times. How can I change ...
0
votes
1answer
155 views

How to delete all ufw rules for a certain port?

I am using ansible to configure ufw on my DB servers to only let accept connections from certain servers connection to a specific port (lets say 1234). When a server that used to have access is taken ...
3
votes
2answers
86 views

Why is my find -type d performing fstat on every file in a folder?

I'm running find . -type d on a rather large directory tree. I am only interested in finding directories within this tree, but when I ran an strace against the process to make sure it was doing what I ...
3
votes
5answers
2k views

prevent xargs from quitting on error

According to the man page, xargs will quit if one of the execution lines exits with an error of 255: If any invocation of the command exits with a status of 255, xargs will stop immediately ...
0
votes
1answer
68 views

Cron bash script skips second do/done set

I have a script that checks IPs for ping reply then tries to run an snmpwalk on them. I am trying to schedule the script to run weekly in cron. When I run the script in the shell, it runs perfectly. ...
0
votes
0answers
82 views

AD Authentication with SAMBA, Winbind and SSS

I'm having trouble authentication with AD to a SAMBA share on a linux server. Authentication appears to be working, but only halfway... [root@myserver ~]# wbinfo -a my_ad_user%password123 ...
5
votes
2answers
2k 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 ...
3
votes
4answers
149 views

Remove IP with ip command in linux

If I add two IPs like this: ip addr add 1.1.1.1/24 dev eth2 ip addr add 1.1.1.2/24 dev eth2 and then I try to delete one of like this: ip addr del 1.1.1.2/24 dev eth2 BOTH IPs will be deleted ...
1
vote
2answers
3k views

Bash script count down 5 minutes display on single line [closed]

I would like to have a count down of 5 minutes, updating every second and showing the result on the same line. Is this even possible with Bash scripting?
0
votes
2answers
750 views

Can't run AWS CLI from CRON (credentials)

Trying to run a simple AWS CLI backup script. It loops through lines in an include file, backs those paths up to S3, and dumps output to a log file. When I run this command directly, it runs without ...
0
votes
2answers
42 views

Using find to exclude a directory and tar up everything else in a directory

I have following in a directory: dir1 dir2 file1 file2 I want to tar up everything except dir1 When I do: find . -path '*dir1*' -prune -o -print I don't see dir1 in the output ( as expected) ...
1
vote
2answers
42 views

Hourly Clamscan cron script failes at reading file list

I've this piece of code located in /etc/cron.hourly/hourlyclamscan. #!/usr/bin/bash # Create Hourly Cron Job With Clamscan # Directories to scan SCAN_DIR=/home/transmission/Downloads # Temporary ...
3
votes
1answer
42 views

List directories not containing a file which has a variable prefix

I'm checking the output from a script. In some cases the script has failed, and a certain file hasn't been produced. I want to check whether this file is present in a directory and if not, print the ...
-1
votes
2answers
109 views

Delete all files except the newest of each day

I have dump directory that is filled at the rate of one file per 4 hours. I wish to keep all files for a week then delete all except the newest of each day. Bash is preferred though other solution ...
0
votes
3answers
87 views

how to run the dialog command with proccess

Please look on my code – ( bash script ) I want to display both dialogs on the screen on the same time, one dialog display the: tail –f from - /var/log/proccess1.log , and the second dialog ...