Questions tagged [bash]

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

bash is the Bourne Again SHell, the successor to the classic Unix Bourne shell (sh). It's the default shell on many Linux distributions, including RedHat, CentOS, Debian, and Ubuntu.

The premier online guide is the BashGuide.

3527 questions
1
vote
2 answers

Issue with the combination of ssh, bash --login and exec

Here are few situations I'm in. foo is the ssh server to which password less login is set up. $ ssh foo $ bash --login -c 'exec $0 "$@"' ls -lrt It's working as expected. ssh foo bash --login -c ls -lrt This is not working as expected. Only ls is…
RatDon
  • 189
  • 1
  • 1
  • 6
1
vote
2 answers

Execute local alias through ssh on remote server

I know I can execute a function through SSH on a remote server like so: $ ssh remote_server "$(declare -f cool_function); cool_function" I also have some aliases that I would like to execute on remote servers without having to define them on any…
MauricioRobayo
  • 152
  • 1
  • 14
1
vote
1 answer

How to escape double quotes and exclamation mark in password?

I have the following code: curl -s --insecure -H "Content-Type: application/json" -X POST -d "{\"username\":\"$1\",\"password\":\"$2\"}" http://apiurl In the above curl command I want to escape the " and ! in the password. I have modified the curl…
me24hour
  • 11
  • 2
1
vote
0 answers

Unable to connect via SSH to "Bash for Windows" (WSL)

I'm trying to SSH from my linux box to WSL and no luck so far. I've…
Perlator
  • 111
  • 2
1
vote
1 answer

Passing jinja variable to script from salt pillar

Using salt to provision and I want to be able to run cmd.script. The script works if i list all packages i intend to install within the script. But i will prefer to have the list of packages in salt formula and refer to it from the script. Below…
1
vote
1 answer

Bash loop failing when sub-process changes files on disk

This code has been failing for days and I'm at my wit's end. Maybe someone can help. I've coded a bash script that is supposed to loop through managed Linux systems. It calls another bash script to get records with 8 fields: local…
1
vote
1 answer

Unable to get vm-list for KVM using nrpe check

I created check in KVM virtualized host to get list of available VM's in KVM hypervisor using below command. $ cat /usr/local/nagios/libexec/check_kvm #!/bin/sh val=`virsh list --all | sed '1,2d' | sed '/^$/d'| awk '{print $2":"$3}'` echo "VM List…
Paul Jany Godwin
  • 81
  • 1
  • 1
  • 8
1
vote
2 answers

Bash script to transfer folder recursively without overwriting via FTP

I would need a bash script to transfer folders recursively via FTP. Username/password/IP - static defined. Server where the script runs on: Linux Source server: Samba (Linux...) Dest. Server: Linux As the files to be transferred are big database…
laurens
  • 397
  • 4
  • 19
1
vote
1 answer

SELinux - Script uploaded SSH keys to remote server but cannot connect via SSH

I wrote this script which now works perfectly on systems without SElinux installed. echo Enter server IP: read server scp /home/Zenoss/.ssh/authorized_keys random@$server:/home/random sshpass -p randompassword ssh -t random@$server sudo -i…
Matt B
  • 99
  • 1
  • 1
  • 9
1
vote
1 answer

NetworkManager up scripts running twice

My system, Ubuntu 16.04, uses NetworkManager. In order to hook an interface up event I have placed a script in /etc/network/if-up.d/. The head of the script looks like: #!/bin/bash NETIF="enp2s0" if [ "$IFACE" != $NETIF ]; then exit…
Twifty
  • 141
  • 4
1
vote
0 answers

Apache: Add custom tmp-Dir for every vhost

I need to change the existing vhost-configuration files. My goal is to add an custom tmp-path to every host-config, that is stored at /configs. Maybe it would be possible to include an additional config-file in every vHost-config, that allows to set…
SPQRInc
  • 151
  • 1
  • 5
1
vote
2 answers

Permanent way to execurte a command for root on system startup in Mac OS

On Mac OS my CI server's build agent runs as root. I have messed with the ruby version on by defaul ruby -v reports version 2.0, while after eval "$(rbenv init -)" is being executed, I get a desired 2.4. If I were to set the eval "$(rbenv init -)"…
Maxim V. Pavlov
  • 663
  • 3
  • 11
  • 29
1
vote
3 answers

removing first and last character on each line / sed

I need sed to remove first and last character of the line for instance source (192.168.3.0) result 192.168.3.0 trying this way: sed 's/^.\(.*\).$/\1/' but then it removes 0 character as well how to-avoid this behavior ?
user387694
1
vote
2 answers

BASH - sed replace IP variants

It's been awhile since I've posted a question on here. Need some assisteancew getting my sed to work. I've tried all kinds of forms of sed options, but can't seem to get this working. I have a file that has "192.*" all over it, and need any type…
drewrockshard
  • 1,763
  • 4
  • 20
  • 27
1
vote
1 answer

Delete all folder not containing filename matching glob/regex

I want to do the following. I have depth 2 file hierarchy like this: A | B | | g | | h50000 | C Where A, B, C are folders. I want to delete all folders without files matching specific patters, (in my case 50000 is pattern, glob style) on depth…
nmiculinic
  • 113
  • 4
1 2 3
99
100