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

learn more… | top users | synonyms (1)

0
votes
1answer
1k 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 = ...
0
votes
1answer
65 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, ...
-1
votes
0answers
14 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
32 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
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 ...
8
votes
6answers
5k 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
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
12 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'. ...
173
votes
5answers
65k views

What is the difference between double and single square brackets in bash?

I just wondered what exactly the difference between [[ $STRING != foo ]] and [ $STRING != foo ] is, apart from that the latter is posix-compliant, found in sh and the former is an extension ...
1
vote
2answers
22 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 ...
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 ...
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 .. ...
0
votes
1answer
28 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 ...
9
votes
4answers
12k views

Determine if file is in the process of being written upon?

I need to deploy an automated process (via 1 min cron script) that looks for tar files in a specific directory. If a tar file is found, it is untarred to the appropriate location and then the tar file ...
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 ...
66
votes
10answers
38k views

How to create a UUID in bash?

In Java i can create a new random UUID with UUID uuid = UUID.randomUUID(); I now need to do the same within a bash script. Is there a command or library I could use?
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 ...
23
votes
4answers
13k views

How can I check in bash if a shell is running in interactive mode?

How can I tell (in ~/.bashrc) if I'm running in interactive mode, or, say, executing a command over ssh. I want to avoid printing of ANSI escape sequences in .bashrc if it's the latter.
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
4answers
366 views

Useradd and su strange terminal behavior

I used useradd to create a user called oracle After that I used su oracle i get in terminal just a $ Do you know why the terminal is not something like oracle@laptophp:~$ and is just a $ ?
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" ...
4
votes
2answers
10k views

How do I reclaim a disown'd process?

Similar to many previous questions, I found myself running a job that I wish I had run in screen. I was forced to disown the process because I needed to disconnect. Now that I have reconnected, I see ...
1
vote
1answer
596 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 ...
10
votes
3answers
10k views

iftop - how to generate text file with its output?

iftop is great tool to view almost live bandwidth usage distinguished by source-ip source-port destination-ip destination port. I'm using it to see which client's ip is using most bandwidth. Now I ...
-1
votes
1answer
24 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 ...
16
votes
6answers
23k views

How do I pipe a downloaded file to standard output in bash?

How is it possible to pipe out wget's downloaded file? If not what alternatives should I use?
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 ...
6
votes
2answers
2k views

How to pass input from one script into another using bash

I am writing a script where I am want to launch the mysql_secure_installation script and provide the appropriate answers at each prompt. I tried using echo like this: echo -e ...
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 ...
15
votes
6answers
21k views

From a shell script, how can I check whether a MySQL database exists?

mysqladmin -uroot create foo returns an exit status of 1 if foo exists, and 0 otherwise, but of course it will also create the database if it doesn't already exist. Is there some easy way to simply ...
7
votes
5answers
12k views

How to parse and convert ini file into bash array variables?

I'm trying to convert an ini file into bash array variables. The sample ini is as below: [foobar] session=foo path=/some/path [barfoo] session=bar path=/some/path so these become: ...
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 ...
3
votes
4answers
10k views

control a bash script with variables from an external file

I would like to control a bash script like this: #!/bin/sh USER1=_parsefromfile_ HOST1=_parsefromfile_ PW1=_parsefromfile_ USER2=_parsefromfile_ HOST2=_parsefromfile_ PW2=_parsefromfile_ imapsync \ ...
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 ...
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
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 ...
1
vote
2answers
280 views

Catch all emails and pipe them all to a script with postfix

I realize this question was asked and answer before. Here's what I have done. Created a catchall address and user. Here is my /etc/postfix/virtual file. @example.com catchall Added it to main.cf. ...
-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 ...
3
votes
7answers
11k views

Escape a star (*) character in bash

I just cant do it. If * is in a variable, it expands to a list of files in current folder. echo "*" works fine. #!/bin/bash c="GRANT ALL ON \*.* TO '$1'@'localhost';" mysql < $c exit 0;
1
vote
3answers
1k 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 ...
4
votes
1answer
55 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 ...
14
votes
4answers
5k views

Do background processes get a SIGHUP when logging off?

This is a followup to this question. I've run some more tests; looks like it really doesn't matter if this is done at the physical console or via SSH, neither does this happen only with SCP; I also ...
1
vote
1answer
1k 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 ...
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 ...