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
1
vote
1 answer

How to delete the grepped iptables

I have iptables starting from cali- root@Ubuntu-18-VM:~# iptables -S | grep -oP '(?
solveit
  • 265
  • 1
  • 4
  • 12
1
vote
2 answers

Bash script - check if a variable is located between 2 others variables?

In a Bash script I want to check if var1 is located between var2 and var3. But I can't find how to do it. Something like this. var1=15 var2=10 var3=20 if [ "$var1" is located beetween "$var2" and "$var3" ] then echo "ok" else echo "not…
Maxime
  • 69
  • 7
1
vote
1 answer

How to calculate CPU and memory utilization on solaris box

I am trying to write shell script to calculate memory and cpu utilization on solaris box. For CPU utilization, I tried below command but I want to append date, time and host name in same command but on solaris I am unable to append sar -u 1 | awk…
1
vote
1 answer

I'm not good at scripting...How best can I update the IP address on a debian server running live from PXE (DHCP reservations are not an option)

This is more a brain dump than anything at this point, but I'm stuck and help would be appreciated! I have a really complicated set of limitations on 3 of my servers that necessitated running the OS from a ram drive. Long story short, I have a group…
rudepeople
  • 35
  • 6
1
vote
1 answer

How to use sed text processing

please i need your help on this topic. i have 3 temp files and nbf.txt. i want to copy each hour lines from this 3 temp files to nbf.txt: inside each temp file we have temp file for each hour: tmp1 Receiveid…
Network
  • 11
  • 2
1
vote
1 answer

Use file creation date as archive name in batch archiving (7zip)

So what I basically want to achieve is to make archive of each file in a specified directory and so the name of resulted archive consisted of compressed file creation date. Say we have some directory in which file A is located. The creation date of…
Kaim
  • 11
  • 2
0
votes
2 answers

shell scripting with expect and a complex command line: no such file or directory

I'm trying to make this work #!/usr/bin/expect spawn "(psql blabla \"blabla sql;\" &> /dev/null) && (pg_restore -d xx my_file.sql &> /dev/null)" expect "Password for user my_base: " send "v" But I always get: spawn (psql blabla "blabla sql;" &>…
Olivier Pons
  • 622
  • 1
  • 5
  • 22
0
votes
2 answers

Parallelize curl requests

This is my shell script: for i in `seq 1 $1`; do filename=randomfile$(uuidgen).txt head -c $2 $filename checksum256=$(sha256sum $filename | awk '{ print $1 }') attrs=$(jq -n --arg cf "$checksum256" '{…
Jordi
  • 261
  • 1
  • 7
  • 15
0
votes
0 answers

High CPU utilization from a script

I found this script is running in my system without any knowledge. #!/bin/sh if test -r /tmp/.txl/bash.pid; then pid=$(cat /tmp/.txl/bash.pid) if $(kill -CHLD $pid >/dev/null 2>&1) then sleep 1 else cd /tmp/.txl ./run &>/dev/null exit 0 fi fi Also…
Manikandan Ram
  • 399
  • 2
  • 15
0
votes
1 answer

why /var/spool/abrt/ folders not deleted

we try to delete all abrt folders as the following ( on redhat Linux machines ) find /var/spool/abrt/* -type d -exec abrt-cli rm '{}' \; rm '/var/spool/abrt/ccpp-2018-09-03-14:52:11-5653' rm '/var/spool/abrt/ccpp-2019-03-26-12:18:52-31410' rm…
shalom
  • 461
  • 13
  • 29
0
votes
1 answer

While schedule below script through crontab receive incorrect output date format is going wrong

PFB script dd=$(perl -e 'use POSIX;print strftime "%Y%m%d",localtime time-172800;') Date=$(perl -e 'use POSIX;print strftime "%d%m%Y",localtime time-172800;') for i in `cat /path/Path_CDR.txt` do cd $i compress event*$dd*.asn compress…
Bhushan
  • 1
  • 1
0
votes
1 answer

Not able to access value of a jenkins groovy variable in shell script for loop

When i am passing value of a variable declared in jenkins Groovy script its value is not retained in "for" loop which runs on a remote server. Strange thing is i am able to access the same value on remote server outside the for loop. Here is the…
NoobCoder
  • 1
  • 1
  • 1
  • 1
0
votes
1 answer

Bash command to execute a foreground set of background commands

I got 2 commands that run blocking the input in the console, so they must be ended with CTRL+C. I don't like running them in background, since I lost control for interruption. But otherwise I cannot execute them sequentially in a one-liner since…
Whimusical
  • 103
  • 4
0
votes
1 answer

Script to automate data population once windows VM in GCP started

I need to know if there is any way I can build a script which can be executed as soon as my windows VM is started in GCP. This script should(Other than RPA solution) be able to open a web browser and fill 3 consecutive pages(text fields, radio…
0
votes
0 answers

Command not found error throwed about function on shell script called with bash and curl after sudo su

When doing: #!/bin/bash function01() { echo "Func01" } function02() { echo "Func02" } function03() { echo "Func03" } clear function01 function02 #sudo su function03 and calling as: curl http://192.168.1.1:80/myScript.sh | sudo bash …
Mark
  • 91
  • 1
  • 9