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

learn more… | top users | synonyms (1)

-1
votes
0answers
13 views

how to increase the last digit of strings if string like abc@0021 using bash script [on hold]

Actually i have string in test.txt file. consider the string is abc@0021 so i want to increase only the last digit of my string using bash scripting and the output will be like.... abc@0022 ...
1
vote
1answer
31 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
17 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
11 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
33 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
21 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 ...
-2
votes
0answers
32 views

Using Screens with a PHP Script [migrated]

I found an external developer to make me a PHP script to 'snipe' Mineraft usernames. In order for it to operate, I have to start the script from the command line using this: php -f sniper.php > ...
0
votes
1answer
21 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 ...
0
votes
0answers
30 views

BASH script presenting IF syntax error [migrated]

for k in {794..800} if [ -f "vesta_$k.xyz" ] then do mkdir $k mv vesta_$k.xyz $k/vesta.xyz cd $k/ <<COMMANDS>> cd .. ...
3
votes
1answer
49 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
30 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
15 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
37 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
27 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
23 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
22 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
26 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
21 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
27 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
0answers
27 views

linefeed in bash script - to email [migrated]

I am doing printf to a logfile and having that logfile send through mailx, however, it seems that the linefeed "\n" are not recognised or captured in the mail. Snippet of script as below (notice the ...
0
votes
1answer
13 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
24 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
44 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
38 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
64 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, ...
2
votes
0answers
48 views

Linux bash: Search and replace in file without escaping hassle [migrated]

Is there any bash solution to do a simple "search and replace" without escaping hassle? I try to replace <!-- JavaScript --> in an html file with the content of a complex javascript file. I ...
7
votes
0answers
1k views

What's wrong with this for loop in bash script? [migrated]

I am trying to print a simple value for $AR1_p1 but the variable $i is not evaluating. for i in 1 2 3 4 do AR1_p1=22 AR1_p2=23 AR1_p3=24 AR1_p3=25 echo $AR1_p$i done It's like concatenating ...
0
votes
0answers
26 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
34 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
51 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
58 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
77 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
41 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
54 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
43 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
47 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
32 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
0answers
35 views

Script to block domains that send too many messages

I've written a little script that will block a domain name from sending email after it has queued more than X amount of messages exim queue. I don't know if this is the right way to go about it, can ...
1
vote
2answers
62 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
37 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
21 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 ...
1
vote
3answers
51 views

Best Practice to obscure path to keypair in bash_profile?

I have dotfiles saved in a public github repo, which include the path to my aws keys, which seems like a terrible thing waiting to happen. So it's like this: function superssh { ssh user@something ...
1
vote
0answers
16 views

io error on no-match glob within cifs OSX -> debian jessie mount

Using a wildcard/glob (at least * and ?) in bash causes an input/output error when there are no matches on a samaba cifs mount in Debain Jessie 8.2. On other filesystems, the expected No such file ...
3
votes
2answers
106 views

Bash commands run at terminal but not in Jenkins/Bash Script

I'm using Jenkins to build and deploy HTML documentation to a local Apache web server for our devs to use. When I run the commands in the terminal, everything installs properly (Proving the server is ...
3
votes
1answer
29 views

Stuck at single angle-bracket prompt

I experimentally ran if bat1 == 1 then echo yes fi and am stuck in a single-angle-bracket-prompt purgatory in which Ctrl + c or z fails to open the door. Any suggestions?
0
votes
1answer
34 views

getting a list of live assets using nmap and script?

I'm playing around with a way to find all network assets from the command line that will return an IP, a hostname, and then have a way to see all interfaces associated with that host. I was using ...
0
votes
2answers
56 views

How to ensure that the script and its command get killed once terminal is closed

I have written a script and it is working fine . It do some tail and grep operations. When I am closing my terminal and the greping the PID of my script , I can find the script is still present in ...
0
votes
1answer
19 views

Error creating a Ruby launchd task with RVM in OS X

I want to periodically run a ruby gem based command. I am using RVM and following the tutorial set out here. My ruby task is called daily_checks.rb and is as follows: #!/usr/bin/env ruby puts 'in ...
3
votes
1answer
53 views

Bash shell script executing out of order when passed over stdin to LXC container

I am passing the following simple shell script to bash on an LXC container: apt-get update apt-get install postgresql -y sudo -u postgres psql -c 'create database dvdrental;' The actual command ...