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

Automated speed tests with a curl command

I'm having some hard time finding examples of something relatively simple: At my job, I need to come up with a script to test various servers with curl and then get the outputs in a file. The command to use is something along $ time curl…
Notauser
  • 295
  • 1
  • 9
0
votes
1 answer

get a specific line from in linux using grep

Hello I am new to linux and grep and awk commands. I am trying to get the number value from this string variable and then store it in another variable. var1="Version must be incremented on update. Current version is: 532" var2=var1 | grep "?" What…
Alex
  • 172
  • 1
  • 1
  • 8
0
votes
2 answers

Arping does not work in a script

In my network I have one linux host as a default gateway located at 192.168.150.1. On another host at 192.168.150.4 I have this script to measure time between sending an arp request and receiving it: #!/usr/bin/env bash for i in $(seq 30 $END); do …
Fleuri
  • 255
  • 3
  • 12
0
votes
1 answer

detect network status even if it is disconnected for a millisecond shell script

I have this shell script which keeps running continously. #!/bin/sh while true; do ping -c1 www.google.com > /dev/null; done When I disconnect my lan cable this script throws error in the terminal ping: unknown host www.google.com but it takes…
node_man
  • 101
  • 2
0
votes
0 answers

Error while running shell script, Please check the error generated below

Can someone help me what's wrong with below script. START=$(date +%s) Sta="2 4 8 10 20 40 60 80 100 150 200 250 300 300 400 450 500" for staNodes in $Sta do ./waf --run "scratch/freeze-count --staNodes=${staNodes} --simulationTime=10…
0
votes
1 answer

How can I compute only current instance disks

I need some help with Google cloud. I need a shell script for creating a current instance snapshot. I have researched and found some shell script which can create snapshots for all project instances, but I don't want to give access to another…
0
votes
1 answer

Prefixing iostat with the current time

I'd like to prefix my iostat output for device sda with a timestamp. Y-m-d H:M:S would suffice. This does not seem so straightforward however. My first attempt was simply: # vi just_echo …
Server Fault
  • 3,714
  • 12
  • 54
  • 89
0
votes
3 answers

Allowing SSH To use ssh-agent in bash script

I am working on recon for a set of systems my company is taking over and they use a different authentication method than we do. Specifically we use AD auth and a jump server to access systems where they use a mix of Keys, passphrases and others for…
Ryan Smith
  • 43
  • 2
  • 8
0
votes
1 answer

How to replace some character from a string in UNIX?

I have two string like this... a=[2018:08:22-15:26:18:26182619] b=[2018:08:22-15:26:18:26182619] And I want to convert a= 20180911183706376476 b= 2018082215261826182619 Can anyone please help me out?
0
votes
2 answers

How to print true if condition in shell script

I'm writing a script to change few setting according to location and to do this i selected hostname as a benchmark. My aim is, if my hostname condition comes true then do this. For this i'm writing a shell script which is comparing few thing in …
root
  • 39
  • 2
  • 8
0
votes
1 answer

Defining array in shell script

I am trying to define array in my shell script which would have content like below cassandra_hosts=(cassandra1.test-dev.local cassandra2.test-dev.local cassandra3.test-dev.local) But it doesn't let me define it and gives error as below. -bash:…
Shailesh Sutar
  • 1,517
  • 5
  • 23
  • 41
0
votes
0 answers

sed + delete duplicate lines except the first one according to specific request

in /etc/services file I can see duplicate lines for example the following line is duplicate ( or more ) odasrv 2432/udp so it can easily deleted by sed as the follwing sed -i '/codasrv 2432\/udp/d' /etc/services but the problem…
shalom
  • 461
  • 13
  • 29
0
votes
1 answer

Grep returns nothing

This is the grep command I used grep -ic address log* The output is 0. I know for a fact that there are more than 60 occurrences of the word address in the log file. But I still get 0. Now, I copied the contents of the log into a new file log2 …
searcot jabali
  • 281
  • 1
  • 2
  • 6
0
votes
2 answers

GCP Instance startup script error

Trying to add a startup script following the sample here: https://cloud.google.com/compute/docs/startupscript The instance is created with no problems but the script does not execute. Console shows the following output: Jul 28 15:54:39…
RT2 Tech
  • 11
  • 1
  • 3
0
votes
2 answers

Bash script: save last line output from terminal

I am writing a bash script in which I would like to save the output of the last command in to a variable before running my next one so I can display it later. I have tried a few different methods using tail with no success. Any help will be very…
0siris
  • 13
  • 1
  • 7