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

learn more… | top users | synonyms (1)

0
votes
0answers
29 views

nginx stop logging after crontab modified the log file

I have a web server(django) running on nginx + gunicorn. nginx writes its regular logs to: ~/myproject/log/access.log and it writes errors to: ~/myproject/log/error.log it works pretty well for ...
1
vote
1answer
57 views

Is there a way to make these two docker bash commands execute synchronously?

I am automating the setup of dev environments for my app and when I run these two commands manually from the command line I have to wait around 10 seconds after running the first one to run the second ...
0
votes
2answers
34 views

Is it possible for a child script to write output to a parent process?

I have a notify script kicked off by keepalived daemon process whenever it's state changes. The problem is, echo output from my notify script does not appear in the output displayed when running ...
1
vote
0answers
28 views

How to get the output of the python script executed in aws instance

I am trying to automate the aws instance setup using boto. I have a python script in which I will do the ssh to the instance. After ssh,I am executing a python function which is in remote python file ...
1
vote
0answers
23 views

How to display init output to tty7 (or main tty)

I have created my first init script in a linux server (ubuntu if that adds any information) that checks for an update, downloads it and executes it in each hour. The init file is as follows: ...
1
vote
1answer
83 views

Difference between sudo /bin/bash and sudo su to access root

I am aware that there are at least 2 ways to escalate to root privileges when in the terminal, and am genuinely curious as to whether there is a differences / are differences as to what can be ...
6
votes
1answer
72 views

Ensure that no console sessions are left logged in (Linux)

On a Linux system with bash as a default shell, I want to configure automatic logout with the following criteria: Console sessions (VGA, serial, remote KVM, etc.) are logged out after a specified ...
0
votes
1answer
47 views

printing a children's full tree recursively in bash script

sry for not being familiar with question conventions since im new here. i want to write a script that prints the full children's tree recursively of a given pid. i got so far as: ps h -ef | awk ...
3
votes
0answers
52 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 ...
1
vote
0answers
15 views

Generating and testing variable from a MAC vs PC in Linux Bash script

I am supporting two groups. I have one script, and I would like to keep it at one. I am having trouble with a test function: convtype=./Sample*/ if [[ -n convtype ]]; then where it runs fine for ...
7
votes
2answers
386 views

Why does `crontab -` remove crontab, and can it be cancelled?

I hurried and forgot the e in crontab -e before I hit Enter. A prompt appeared, so I closed with Ctrl+D, same as I usually exit input prompts. Now, without warning, my entire crontab is empty. ...
0
votes
0answers
59 views

Interpolating bash variable containing quotes into a command breaks it

I'm trying to split out some parts of a docker command that I have into bash variables. What I had previously, works fine: DOCKER_ID=$(docker run -e CGO_ENABLED=true -e LDFLAGS='-extldflags ...
0
votes
1answer
37 views

Ceph installs without init scipts. How do I get them?

I have installed ceph in 3 centos7 nodes with ceph-deploy tool. All works good but I haven't any script to manage ceph or radosgw. My /etc/init.d/ folder contains only these: functions, network, ...
1
vote
1answer
29 views

Issuing a single command from a cluster of servers?

I have a cluster of servers that will be running a simple ruok command with fallover. The command will be something simple like curl -X POST http://foo.com/status. Due to the fact that I will have ...
0
votes
3answers
51 views

Matching first block of text from a file, between 2 strings

I'm trying to match only the first block of text between 2 strings: 'menuentry ' and '}' from a file as follows: Input file: (some irrelevant text) menuentry 'My Customized Linux, with Linux ...
1
vote
1answer
100 views

Testing HTTP/2 using `openssl s_client`

CloudFlare’s blog post on tools for debugging, testing and using HTTP/2 mentions this approach to finding out which protocols are supported by a given server: $ openssl s_client -connect ...
0
votes
2answers
19 views

How to grep ifconfig and replace in file?

I am trying to make a script that greps the eth0 ip address and put it the 6th line in a specific file. I have tried this newip= $(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print ...
0
votes
1answer
15 views

grep the result of cdrecord or wodim

I would like to parse the result/progress of a running cdrecord -v burn process. What I tried so far was cdrecord -v dev=/dev/sr0 -data foo.iso 2>&1 | grep -E 'Track [0-9]+:.*written'. ...
0
votes
1answer
47 views

httpd reload as second command in bash fails

I am trying to run a command that carries out one action, to renew a certificate, and then reloads Apache. To do this I am running the following: sudo /home/ec2-user/letsencrypt/letsencrypt-auto ...
1
vote
2answers
25 views

Answering Dialoges with Bash

I need to automatically answer all dialoge (blue screenish Text GUI) questions when running dpkg-reconfigure exim4 as I have a bash script which will run on many servers. Is there some way to ...
0
votes
1answer
25 views

run a script that prompts for input just in command line

Testing a batch script, I execute it in bash. I want to see prompts and respond by inputting variables. For example, the following works, but I want to prompt for these inputs, not put literals in my ...
3
votes
1answer
58 views

Find network percentage of NIC [closed]

So I have created a Linux resource monitoring tool that pulls various resource information. One of the fields I am trying to pull is the percent of network throughput on my NIC. So if I have a 1 ...
3
votes
2answers
50 views

Compare string on shell script

I'm creating a script to check the requirements about VM in one of my customer. The first part of the script is check if the OS is virtual or not. To achieve this goal I create the following script. ...
1
vote
2answers
30 views

Git post-receive hook hanging

I have a git post-receive hook which builds a Go program and runs it. The problem is that I'm getting all the output from the Go program and the git push "never finishes" the execution, getting ...
0
votes
2answers
42 views

What's the default order of “for f in directory/*”? [duplicate]

I wanted to know if iterating over files in directory with for f in directory/* will have some default order of processing entries (file name, created date, etc.?), or is it non-deterministic? It ...
0
votes
1answer
44 views

How can I script the shutdown of a host by a remote server when rsync completes and no users are logged in?

This is what I have so far. This script would run on a Network Services host that does things like DHCP etc... and in this instance should be waking and sleeping computers for backup. #!/bin/bash ...
-1
votes
1answer
43 views

bash scripts work fine when I run it from command line but not from cron [duplicate]

I have this bash script in runtests.sh file #!/bin/bash cd /Library/WebServer/Documents/protractor_clipboards protractor testscript.js When I do this on terminal ./runtests.sh But when I try to ...
0
votes
1answer
27 views

SSH remote execute command with special chars

Im trying to run this from my shell: I have a bunch of machines, so i have this in my .bash_profile function sssh() { ssh -i ~/.ssh/supersecret.pem $@ } This is the command: export ...
0
votes
1answer
65 views

IPMItool, bash script

i need to write a bash script that will go in the server to check the ip address of ipmi, as i read that i can use ipmitool lan print i can write it inside server to show the ip address. but ...
1
vote
0answers
22 views

How to allow a user access to Git [closed]

I have a VPS with multiple users, running Ubuntu as the OS. I have my users chroot to there own directories. What I want to do is allow specific users or accounts access to Git without giving them ...
1
vote
0answers
45 views

How to write a bash script that traps SIGTERM and kills the process and all sub-processes immediately

I have this script: #!/bin/bash set -e #WHAT SHOULD I WRITE HERE? sleep 60 # this is for testing #java ... | logger # this is what will be in the real script I want to be able to kill myscript and ...
0
votes
1answer
19 views

When triggered, run script at top of the hour

I have a service that must be started at the top of the hour, any hour. Whenever that service goes down (during a reboot, etc) PRTG Network Monitor will know. PRTG has the ability to run a script when ...
-2
votes
1answer
37 views

Is it possible to “sudo su” using ssh in bash? [duplicate]

#!/bin/bash USERNAME=ksmith HOSTS="linux1" YUPDATE="sudo yum -y update" FIXDATE="sudo -u echo -e 'ZONE="America/New_York"\nUTC=true' > /etc/sysconfig/clock" for HOSTNAME in ${HOSTS} ; do ssh -tt ...
-5
votes
1answer
47 views

Can I remove a directory “Cancer ” and leave all other sub directories intact for directory “/home/John/Cancer/MillionDollars”?. Bash / Linux [closed]

Get rid of directory “Cancer” but keep directory “Million Dollars” Directory: /home/John/Cancer/MillionDollars Desired Directory: /home/John/MillionDollars This is for later ...
0
votes
1answer
64 views

how to run multiple commands (nested control statements) on remote machines with sudo?

My bash code is: 1 #!/bash/sh 2 set -e 3 USER="admin" 4 HOST="1.2.3.4" 5 PASSWORD="$(cat password.txt)" 6 7 sshpass -p"$PASSWORD" ssh -t $USER@$HOST "/usr/bin/sudo bash -c 'sudo ls ...
0
votes
1answer
118 views

How to dump usb stick with corrupt partition table?

Question at the bottom. When I insert the 8GB usb stick I get this in dmesg [168699.879019] usb 1-4: new high-speed USB device number 24 using ehci-pci [168699.994177] usb 1-4: New USB device found, ...
0
votes
0answers
31 views

how to execute bash script with args in parallel on all the remote server if the remote server in the from of pair

Please read carefully problem first and then give solution................... we are having 3 files in directory myscript.sh (the myscript.sh file contain many function and starts/stop to ...
-3
votes
2answers
39 views

how parallel ssh execute bash scripts with mutiple positional parameter [closed]

Actually I want to execute my script in parallel on all the remote ssh host. so generally I am executing my script like.... <./myscript.sh arg1 arg2 arg3> and its executing but i want to same ...
-1
votes
2answers
67 views

shell script to open many terminals from a parent terminal and execute different cmds

I want to open 5 terminals from a parent terminal and place these terminals on the screen properly so that each terminal can be viewed properly at the same time. Also, i want to execute differnet ...
-3
votes
3answers
73 views

I want a user to run bash scripts with sudo [closed]

So this is for a school assignment. I have a working Bind9 and Apache2 server. I've written 3 scripts that make appropriate changes to the configuration files DNS add zone DNS add record HTTP add ...
-4
votes
3answers
81 views

Kill A pid only if it is specific Program/Process [closed]

Assuming that we have a PID Number how do i write ONE bash command to kill it if it is is specific program? For example let's that that we have a pid number 20000 . I want to kill that PID only if it ...
3
votes
0answers
89 views

lspci “Memory at…” vs /proc/bus/pci/devices BAR address

I have a userspace application that I use to write to the registers of a pci device. It takes the base memory address of the device as an argument. Instead of looking this up via lspci on each ...
4
votes
1answer
128 views

Bash to start missing debugger after update to 4.2

I'm on Centos 7.2. Yesterday I've made an update of bash to version bash-4.2.46-19.el7.x86_64 and now on login I get this: -bash: /usr/share/bashdb/bashdb-main.inc: No such file or directory ...
1
vote
2answers
79 views

unable to run generated python (selenium) script from PHP

I have an Ubuntu machine for headless selenium tests. I generate a python script in /var/www/tmp/random123name.py via PHP and execute them. The script works when run from command line user, fails ...
4
votes
1answer
34 views

Is There a Difference in Methods of Command Execution in a Subshell?

I wonder if there is a significant difference of calling sub shell via $(...) or `...`? For example: a=$(ls -la /tmp | grep vox-*) And: a=`ls -la /tmp | grep vox-*` The result will be the ...
4
votes
2answers
57 views

Missing Feature in check_tcp Nagios Plugin

I've got a problem with the check_tcp plugin from Nagios and could not find any plugin that works like I need. I'm sending a string to a port via check_tcp and get a number back, in this case 2580. ...
2
votes
1answer
39 views

Is this possible to deny logout with bash shell .bash_logout?

I wish to use this .bash_logout script to check some things before the user log out and possibly deny to log out if things to do remains. My use case is to check if a git repo is clean before ...
1
vote
2answers
66 views

Bash script OR issue

I have the below script and basically what I want it to do is connect to the various servers. See how many open files there are, and sent an email if its over 50,000. But the last server I need this ...
-1
votes
1answer
39 views

Syncing MySQL backup with GIT tags

We have a large Yii2 / PHP application using MySQL database and versioned by GIT. The application is under continuous development as customer require new features. The database gets changed quite ...
0
votes
0answers
22 views

fileschanged daemon dies unexpectedly

I'm using fileschanged to monitor files on server1 and run a bash script to synch the files in server1 to server2 if any of the files are changed in server1. to do that I'm running this: fileschanged ...