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

learn more… | top users | synonyms (1)

2
votes
2answers
2k views

Shell script for docker ps -a | grep to find number of certain containers running

I want to write a script that is executed by my development build server that will remove any 'similar' docker containers before building and running a new container. Below is pseudo code for the ...
0
votes
1answer
2k views

Monit failed to start shell script

So I am having a problem with monit starting a process this is my code: check process program_1 matching "program_1" start program = "/home/user1/files/start.sh" stop program = "/home/user1/files/...
1
vote
1answer
2k views

Nginx how to run shell script on page load via lua module os execute and then serve directory listing?

So I have a bash script that I want to execute/run on each "page load" of url so that it will modify (creating symlinks) to a /public/html/ folder that I want the server to then serve. The problem ...
1
vote
1answer
24 views

systemd service shuts down on its own

I have a problem with this SystemD service: [Unit] Description=RTC Client Services After=rds.service Requires=rds.service [Service] User=USER Group=GROUP PermissionsStartOnly=true RuntimeDirectory=...
55
votes
3answers
20k views

What are the functional differences between .profile .bash_profile and .bashrc

What are the functional differences between the .profile, .bash_profile and .bashrc files?
0
votes
0answers
31 views

joint two conditions in bash script

I have this conditions in bash script (bin/bash) .sh iptables for mac in `awk -F";" '{print $2}'` file1.txt; do rule 1 done and the second part: for ip in `cat file2.txt`; do if echo $ip | ...
3
votes
1answer
72 views

Strange behaviour ssh -> bash --> (tty no echo) --> c program?

At job we have an old C program which works with industrial hand terminals from Honeywell. That terminal has its own ssh client to connect to a linux redhat 6.6 server. Once it is connected to the ...
0
votes
0answers
6 views

parallize postgres queries with bash and psql?

I'm trying to run a series of postgres functions/stored-procedures that operate on separate tables in parallel using bash + psql as follows: psql -d samples_20160612_0616 -c "select insert_function('...
0
votes
0answers
22 views

Install Bash + openSSH on Windows Server 2012

I had to create a Virtual Machine with Windows Server 2012. Now I want to connect to it via OpenSSH and Bash, installing OpenSSH is successful, however when I connect to the server via ssh ...
0
votes
0answers
23 views

If I know the inode of directory, is it possible to recover it after deleting?

More specifically, say I have a directory with lots of files in it. Suppose I know the inode of the directory. Now, if I delete the directory, is it possible to recover the files inside that directory ...
1
vote
2answers
94 views

Docker exec/run shell command nesting

A short introduction to the use case: I am using a docker container to run my go tests using go test ./.... This can be achieved easily using docker exec <container> /bin/sh -c "go test ./..."....
1
vote
2answers
1k views

Inserting multiple lines into a sqlite column with bash script

I am trying to insert a value into my sqlite DB that consists of multiple lines and special characters. For example: { "foo"="$BAR" } I have been using the sqlite3 command but I dont know how to ...
3
votes
2answers
4k views

GNU screen clearing on vim,less,etc. exit

I'm very new to screen but have configured my ~/.screenrc file according to various recommendations I've found on the internet. I have one issue with it though which I'm sure could be resolved very ...
0
votes
1answer
11 views

how to stop esxtop gracefully which is running in batch mode?

I am running esxtop in batch mode using the below command: esxtop –b –a –d 10 –n 2000| gzip -9c > perfData.csv.gz This is going to run for a little over 5 hrs, but I want to stop it gracefully ...
3
votes
3answers
10k views

Apply multiple .patch files

I have a directory with .patch files, generated using diff. I would like to apply all those patches using patch -p1 to another directory. But patch takes only one file, unless I cat. What would the ...
3
votes
2answers
132 views

top output to narrow in cron

I'm trying to send an email through cron to know what processes are hogging my server. It works fine but the resulting email is too narrow and I need to know more about the process. This is the ...
0
votes
1answer
17 views

Systemd don't launch service as intended user

I have this SystemD script: [Unit] Description=RTC Client Services [Service] user=linuxuser WorkingDirectory=/usr/lib/systemd/scripts/ Type=forking ExecStart=/bin/bash rtc_client.sh start ExecStop=/...
0
votes
0answers
11 views

ubuntu script - switching users in script and deleting previous user

On an AWS EC2 Ubuntu Instance I want to run a setup script that creates a new system admin (let's call it deploy) delete the default ubuntu user and continue the setup as the new deploy user. ...
0
votes
1answer
1k views

OpenVPN run script after tunnel is set up

I'm having a hard time figuring out exactly how can I update my A records on my cloudflare account. I have already set up a script that checks for IP changes, and pushes the changes through the ...
0
votes
0answers
4 views

Grid Engine for program that needs X11 but doesn't require user input [migrated]

I have a bash script that calls an executable (some commercial software) in "batch mode". On the commandline, if X is available the program runs to completion and then quits, but if not the program ...
0
votes
1answer
20 views

shell script calls perl script but exits on perl script's completion

I've got a bash script with a while loop that iterates over a list of directories. On each pass, it calls a perl script to do some work. But on the first pass, whether the perl script exits ...
1
vote
2answers
197 views

.bash_profile isn't sourced during logon

I've declared an alias in .bashrc file located in my home directory. Export of PS1 environment variable has been added to this file too. # /etc/skel/.bashrc # # This file is sourced by all *...
0
votes
0answers
37 views

How run script after spamc, use args in script and redirect spamc output to sendmail?

I'm trying to perform custom actions after spamassassin. I have working line in postfix master.cf spamassassin unix - n n - - pipe user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender}...
3
votes
1answer
1k views

Can I recover a nano process from a previous terminal?

My system crashed while I was in a nano session with unsaved changes. When I log back in via SSH I see the nano process still running when I do a ps. davidparks21@devdb1:/opt/frugg_batch$ ps -ef | ...
10
votes
8answers
24k views

How do I read multiple lines from STDIN into a variable?

I've been googling this question to no avail. I'm automating a build process here at work, and all I'm trying to do is get version numbers and a tiny description of the build which may be multi-line. ...
3
votes
1answer
48 views

Determine if Linux OS is booting off a USB

I need to determine (with a bash script) if a Linux OS is booting off a USB. Can we grep some command to find out?
11
votes
6answers
20k views

What command prints a string as “big ascii text art” in bash? [closed]

I'm looking for a program that turns an ASCII string into something like the "ascii art" below: .-"^`\ /`^"-. .' ___\ ...
25
votes
11answers
11k views

Linux: How to use a file as input and output at the same time?

I've just run the following in bash: uniq .bash_history > .bash_history and my history file ended up completely empty. I guess I need a way to read the whole file before writing to it. How is ...
16
votes
6answers
53k views

Determine if filesystem or partition is mounted RO or RW via Bash Script?

Is there an easy way to determine if a mounted filesystem is mounted as Read-Only or Read-Write? I was thinking just to pipe mount but I thought there might be an easier way.
0
votes
1answer
58 views

Extracting From Logs [closed]

I want to grep following information from below raw logs: 2016-05-23 11:01:40 [1005583] 1b4ivg-004DZf-GX ** mustafa@hotmail.com F=<abbas@DomainName> P=<abbas@DomainName> R=dkim_lookuphost ...
1
vote
1answer
78 views

how to run a shell scripts at every login in Centos

Actually i want to run my shell script at every time when a user login as well as at boot. i have tried using using crontab but it runs only at boot not at every login.so please tell me how to do ...
0
votes
1answer
44 views

Check number of connections to webserver port 80 AND 443

As the title says how would one check the number of open connections to a webserver on port 80 and 443? I'm currently using this oneliner to get the number of open connections per ipaddress from port ...
2
votes
1answer
1k 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" ...
2
votes
2answers
919 views

Enable coloured PHP CLI messages on console [closed]

How to enable coloured messages for PHP CLI on console (Mac OS X, latest PHP/Apache from MacPorts)? export CLICOLOR=1 export LSCOLORS=gxfxcxdxbxegedabagacad doesn't seem to be enough, all PHP CLI ...
8
votes
4answers
255 views

Bash one-liner to atomically create a file if it doesn't exist

I want a Bash one-liner that atomically creates a file if it doesn't exist. That means essentially "if file doesn't exist, create it" but ensuring that no one else manages to create the file in the ...
0
votes
1answer
2k views

Using curl with cookies

I hope someone can help me out on this one. I have been trying this for a while now, with all sorts of variations and cannot seem to get this to work. I am trying to script a way to log in to https://...
2
votes
2answers
334 views

How can I set the root password in a docker container from a script?

I have a script that runs on the host and creates/starts/stops a docker container. I'd like the script to change the password of the root user within the container. Since the container is an ssh ...
1
vote
1answer
21 views

How to kill a disowned while loop?

So I've done something like this: $ while true; do ssh sysremote -CN; done & disown % In the ps -ef only ssh sysremote -CN is listed. How do I kill the while loop?
-2
votes
2answers
78 views

Configure OpenVPN with many users [on hold]

Similar to this question I am looking at connecting 1000's of concurrent users: OpenVPN performance: how many concurrent clients are possible? To save CPU cycles I would like to know if there is ...
-1
votes
2answers
37 views

OpenVPN Variables Passed via Script

Can someone explain and/or direct me to a summary of the variables that are available to be passed to OpenVPN upon a client connection? For example, what do the following $1, $2, $3, $4 values ...
0
votes
0answers
23 views

Add Filters to Users

I am running OpenVPN on Ubuntu 14.04 (dev tun) and I can't seem to get my learn-address script to run below I would like to run the learn-address script each time a user connects to OpenVPN that ...
2
votes
1answer
1k views

JBoss EAP 6.2 on RHEL 6: ./bin/init.d/jboss-as-standalone.sh hangs while calling via SSH

I'm using jboss-as-standalone.sh to manage JBoss EAP standalone as a service. I can start/stop the service with "service jboss-as-standalone.sh start/stop" while I'm on a terminal. But I would like ...
0
votes
2answers
15 views

How to direct errors from with a find exec command to a log file

Hi I have the following command that does yui optimizations and runs as a cron job. I want to log the output of the command to a log file. find . -type d -exec bash -c "cd '{}' && pwd &&...
1
vote
0answers
53 views

Bash: Running a background service for the duration of another process

I am running some automated scripts. For some tasks I sometimes need a ephemral background "service" to run. For example, I want to setup an ssh tunnel, run a test, and then have the tunnel removed. ...
0
votes
0answers
29 views

Is it possible to tab through the commandline history for a particular command? [migrated]

For example, can I see all the previous parameters I passed to the command ssh (i.e. all the server addresses I passed as a parameter when calling ssh)? This is going to be something similar to the '...
-1
votes
1answer
32 views

Monit not able to start program in screen

I have monit able to watch the program but the start script is not working. The stop script works just fine. The when monit tries to start it, it just says execution failed. Monit part check ...
0
votes
0answers
46 views

IP not showing in /var/log/secure under rhost

I'm trying to get Fail2Ban to block failed sudo -i commands, but the IP is not showing up in the logs. For example when I log into the server with: ssh -i ~/.ssh/id_rsa USER@1.2.3.4 I then use: ...
7
votes
2answers
10k views

how to filter rsyslog messages by tags

I have several applications and scripts that I want to redirect the output to custom files. I launch those applications using command | logger -t TAG I would like to filter these messages based ...
16
votes
5answers
6k views

SSH from A through B to C, using private key on B

I'm looking for a simple way to SSH from my local machine, A, through a proxy, B, to a destination host, C. The private key that goes with the public key on C is on B, and I can't put that key on my ...
46
votes
6answers
110k 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 ? ...