Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

Generic programming in an Interpreted language (as opposed to compiled) executed by a running Shell. Sometimes referred to as "Glue Code" due to the practice of managing the execution and output of one or more compiled binaries and passing said output to another series of commands.

621 questions
0
votes
0 answers

Running ps command with 'Irix mode' off

I know that within the interactive 'top' screen, I can press 'Shift + i' to turn off 'Irix mode' Is there a way to do the same thing with 'ps' command? I am trying the below mini script to print out the top 10 processes that are consuming the CPU,…
0
votes
1 answer

Ansible blockinfile module - insert insert lines of code

I try to insert lines of code (shell script) with Ansible blockinfile module. name: Customized prompt blockinfile: path: /etc/profile.d/customized_prompt.sh create: yes block: | #!/bin/bash # customized prompt normal user and root if (( "$(id…
Maxime
  • 69
  • 7
0
votes
1 answer

Ansible playbook rebooting the server , wait till reboot complete

I'm facing a issue while executing shell script with ansible playbook. Issue: I'm losing a connection with remote server because shell script is rebooting the server. My Ansible playbook - name: Handle reboot hosts: all become: yes tasks: …
0
votes
1 answer

whats the diffrence between "command.sh > /dev/null 2>&1" vs "command.sh 2>&1 >/dev/null"

I have many shell and python scripts on my crontab that ending either with: command.sh > /dev/null 2>&1 or command.sh 2>&1 >/dev/null I know that: > is for redirect /dev/null is a black hole where any data sent, will be discarded 2 is the file…
Zareh Kasparian
  • 753
  • 5
  • 20
0
votes
1 answer

finding docker images with tag and name

when I do docker images I have below docker images as list where there are images with multiple tag and also image with latest tag value. REPOSITORY TAG IMAGE ID CREATED SIZE m1 …
Alex
  • 172
  • 1
  • 1
  • 8
0
votes
1 answer

how to programatically set nginx configuration directives to nginx.conf?

I am trying to make a shell script to auto install a web app and the script needs to set client_max_body_size to a bigger size, at some point. Of course, it's possible to set this directive using nano but this is not what I am looking for. The…
0
votes
2 answers

cURL POST bash script adds single quotes to variables with spaces

The first 3 variables will always have no spaces. The fourth "slacksitename" has spaces ip=“x.x.x.x" record_name=“demo.xyz" slackuri:”WEBHOOK" slacksitename:”123 Main St" When called with cURL curl -X POST -H 'Content-type: application/json' --data…
northport
  • 3
  • 1
  • 4
0
votes
0 answers

Shell Scripting - Multiple Process ID's instead of one

I'm writing a simple bash script to shutdown tomcat, and if it doesn't stop gracefully then check if the tomcat's PID still exists and kill it. I pass the tomcat name as a variable to the script as below. In some instances I pass two or three names…
Raj K
  • 1
  • 1
0
votes
1 answer

Bash: improper function/usage of command basename

What I want in the following command is to find particular files and move them to the other directories while appending ".log" to the destination filename. find /src/dir/ -type f -mtime +3 -exec mv {} /dst/dir/`basename {}`.log \; But it fails…
aschkant
  • 45
  • 2
  • 6
0
votes
1 answer

Kubernetes limit number of simultaneous pod restarts over whole cluster

We have a 6 node Kubernetes cluster running around 20 large replica set workloads (Java services). Each workload pod (1 pod per workload) takes about 30 seconds on average to start and use a lot of CPU. This makes starting multiple pods/workloads at…
mogoman
  • 101
  • 3
0
votes
1 answer

Expecting a password in the middle of script in RHEL

I want to copy files from another server it's expecting a password to copy... Where as sshpass is working in Ubuntu, but in RHEL is there a way to pass the password in the script.
0
votes
2 answers

Howto start and detach screen with user environment on startup?

I want to start screen and put a couple of programs running inside on startup. I've seen many similar posts but none answered my question. so I put in rc.local following 2 lines: screen -dmS scr bash -c 'ytop; exec bash' screen -S scr -X screen…
DenisZ
  • 38
  • 7
0
votes
0 answers

strings are over-writing variables when using echo

I've currently got an IP address in a variable and I'm trying to echo that variable with some string at the end: echo $INTERFACE_IP echo ":0.0" echo "${INTERFACE_IP}:0.0" And what I'm getting is: 192.168.240.238 :0.0 :0.0168.240.238 Expected…
doublespaces
  • 121
  • 3
0
votes
1 answer

Command works from bash prompt; does not work from within shell script

I'm trying to use IPMITOOL to query a bunch of OOB NICs to get their MAC addresses. When I run: ipmitool -I lanplus -H 1.2.3.4 -U USER -P PASS lan print I get: MAC Address : aa:bb:cc:dd:ee:ff If I try to call it via a shell script…
Driftpeasant
  • 3,217
  • 2
  • 22
  • 28
0
votes
1 answer

Download with Wget only if new version

Good morning, I have a custom software that updates with a custom script.sh. Part of the file goes something like this: if [[ $software == A ]] then echo "downloading package..." rm -rf test.zip >> SoftwareUpdate.log wget --user admin…
Perovic
  • 21
  • 2