Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

Filter by
Sorted by
Tagged with
0
votes
1answer
28 views

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 ...
0
votes
0answers
14 views

How can I send commands to Cyrus cyradm from the shell?

I'd like to delete multiple mailboxes at once using a list of names. I can login to cyradm via cyradm --server=localhost --user=cyrus to use the commands, but the interface seems to be VERY bad. No ...
0
votes
1answer
68 views

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 ...
0
votes
0answers
33 views

Stopping a service stuck via ssh heredoc in a bash script after Centos 7.7 upgrade

I had this logic in Jenkins jobs to deploy code on remote host which was stopping a service and starting again. It was all working fine till recent Centos upgrade to 7.7 (CentOS Linux release 7.7.1908 ...
-2
votes
1answer
31 views

How to convert shell output to excel

Through Linux On executing a shell script I am getting a output which is separated by space. I have to convert this to a excel format. This output should be converted to a excel file which should be ...
-1
votes
1answer
31 views

How to call back to the Main Menu [closed]

Good Day, I'm new in bash scripting, requesting for your assistance. I'm trying to loop my sub menu to go back to the main menu in glassfish. I'm using if statements. I wish for my script to go back ...
5
votes
1answer
247 views

Is it possible to listen to a TCP port only with a shell, with no additional tools? [closed]

I need a very simple web server on a very small embedded system with a MISP processor. I thought that the simplest server could be a shell script listening to a TCP port. The problem is that the ...
-3
votes
1answer
48 views

Find the overall disk size of a linux server [closed]

i have a requirement to check the overall disk size of a linux server. is there any shell script to find the overall disk size. example: serverA -- allocated with 5 disks of below size sda - 100G ...
0
votes
0answers
26 views

How to dynamically change haproxy backend?

I want to know how I can re-map the URL of an application using environment variables.Basically I am looking for something similar to this - frontend http-in mode http bind 206.189.22.155:...
0
votes
0answers
11 views

Script for warming Varnish

I have a setup for ecommerce site with Nginx and Varnish. Although I have a cache warmer in my php application I need a script in server level which will load a txt file for hitting with curl some ...
0
votes
0answers
14 views

How to scriptably and securely verify a GPG key's signatures offline

Given a GPG keychain, with one (or more) imported and trusted GPG public keys for key signing, I want to verify from a shell script that a given public key has been signed by a key already trusted in ...
1
vote
1answer
115 views

Shell script prevent switching to other shell or escape from it

If in my automation script, I need to do something like install oh-my-zsh, I will have a .sh script like this: #!/bin/sh runuser -l user -c 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/...
1
vote
1answer
44 views

How can I make an environment variable visible to a script placed in /etc/cron.daily?

Say I have a script named "mydailyscript" containing the following: #!/bin/bash if [ ! -z $MYDAILYLOG]; then exec 1>$MYDAILYLOG fi echo This script ran on $(date) and I then copy this script to /...
0
votes
1answer
54 views

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 ...
1
vote
2answers
163 views

Using blkid to check if an attached EBS volume is formatted

I have an issue with part of a script that is attempting to check if an attached volume is formatted before formatting. The grep used in this check returns zero when the volume isnt formatted when ...
1
vote
2answers
82 views

Change first character pattern in a file name without changing that same pattern elsewhere in the file name

On a Linux server I have a directory full of files with digits for names. Some of the files start with two zeros such as 00305005. I am writing a bash shell script and one of the steps is to rename ...
0
votes
0answers
47 views

PowerShell script to run with administrator privelage on remote servers

Currently I am using this script to run with with Admin privilege on a remote server, but i have more than 300 servers to do so, Kindly help me with the script Invoke-Command -ComputerName <...
1
vote
3answers
51 views

Writing precisely values of bash script output

I have the following command: $ snmpnetstat -v2c -c public -Cs -Cp udp 10.10.0.32 that has the output: udp: 198 total datagrams received 65 datagrams to invalid port ...
0
votes
1answer
76 views

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 ...
0
votes
0answers
43 views

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: ...
0
votes
1answer
67 views

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 ...
2
votes
1answer
41 views

compare between two times ubuntu shell script [closed]

I am working on a shell script which will do some things if the current time is between 19:00 and 1:00 am, so I get the current time in this way: currenttime=$(date +%H%M%S); and I convert the ...
1
vote
1answer
346 views

script run through jenkins user gets killed

In our jenkins build configuration we have the following shell commands (Execute shell) as the last step of our build process. echo "$USER" echo "Script executed from: ${PWD}" git submodule update --...
1
vote
1answer
224 views

Running a binary as a service in RedHat/CentOS

I have created a script to execute a binary as a service. But the service does not start the service but when i stop the service it shows multiple pids. I am using RHEL 7.Here is the complete details ...
-2
votes
1answer
35 views

How to output one number few times with spaces in one line via bash [closed]

How to output one number few times with spaces in one line via bash I have a=5 b=10 I should output 5 times number 10 with using of variables and with spaces Also, i should capture this in variable ...
1
vote
1answer
44 views

convert date time epoch in miliseconds to UTC human readable format

I am trying to convert date time in epoch to UTC human readable format, I have tried this and this gives me the result in CET but wrong result. perl -e 'print scalar localtime(1549950859468 / 1000) ...
0
votes
1answer
37 views

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. ...
0
votes
0answers
89 views

Compare processed output of command to string in bash

I am not able to get the correct output comparing the output of a specific to a simple string I have tried many different ways but not working so far #!/bin/bash redis_info=$(redis-cli info ...
0
votes
0answers
18 views

Container for testing scripts with the same versions of tools as OSX

Is there any sort of maintained container image that someone has created that contains the same (or very similar) versions of the shell and associated commands as those that are provided by OS X? ...
0
votes
0answers
26 views

Feeding data into InfluxDB using qshape

I have a bash script used to collect qshape data and then this data will be massaged to feed into influxdb database. However this script only able to runing around 1~2 hours before its dead. ...
0
votes
2answers
107 views

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: ...
1
vote
1answer
48 views

shell scripting running service status command and exit

I'm on Ubuntu 16.04. Running service nginx status puts me in a interactive mode with this process. I want to exit, which normally on a terminal is done by pressing q, but right now I'm writing ...
-1
votes
2answers
41 views

Trying to execute this shell script but getting this error

Trying to execute this shell script. #!/bin/bash # Proper header for a Bash script. # Cleanup, version 2 # Run as root, of course. # Insert code here to print error message and exit if not root. ...
0
votes
0answers
28 views

Would it be feasible to detect domains and install Letsencrypt certificates via bash script?

I would like to create a scheduled shell script to do the following on a Centos server: Read the Apache virtual hosts file For every domain detected, check if there is a valid ssl cert in place For ...
1
vote
2answers
169 views

Shell Scripting and Types of Text File Output RE: msinfo32

I ran the following script in my Windows 10 command prompt msinfo32 /report mysystem.txt, which saves all the system data of the machine in a single text file. However, when I ran strings on the ...
1
vote
1answer
56 views

Enter at the end of a specific line

I have the following file.txt that follows the same pattern and I want to modify it where this file is by adding an ip: # gfhfhgfh gfhfghgfhgfhgfh MACs # access USER CONSOLA *,!10.249.247.3,!10.249....
0
votes
1answer
29 views

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 ...
0
votes
0answers
21 views

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 --...
0
votes
1answer
947 views

How to start a jar file using systemd

I want to start java application on system boot using systemd. I tried to do by adding above scripts. But service is not starting. my-startup.service [Unit] Description=Startup [Service] ExecStart=...
1
vote
1answer
78 views

shell script to list directories in decreasing order of disk usage

I am looking for a shell script for Ubuntu Server that lists the disk usage of directories in a decreasing order. It should not list subfolders (recursively). The behaviour should be similar to the ...
0
votes
1answer
40 views

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, ...
3
votes
1answer
500 views

Why is eval not working with command substitution?

I have this command $("${DIR}/test.py" "$1") the output of which is export SOME_VAR="hello world" export ANOTHER_VAR="hello" But eval $("${DIR}/test.py" "$1") seems to do nothing. What am I ...
5
votes
1answer
896 views

Closing All Shared Files on the Network [duplicate]

I am trying to close all of the open files in the shared folders of a server via PowerShell script. I found the following script which only close files on one drive (F:), however, this server has 3 ...
0
votes
1answer
73 views

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 ...
0
votes
3answers
955 views

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 ...
-1
votes
1answer
60 views

How to remove some character from a string in Unix?

I have two string like this a=[2018:09:11-18:37:06:376476] b=[2018:09:11-18:37:06:376446] I want two string like a= 20180911183706376476 b= 20180911183706376446 Can Anyone please help me out?
0
votes
1answer
41 views

How to replace some character from a string in UNIX? [closed]

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 ...
1
vote
1answer
8k views

Jenkins - environment variable not setting up from pipeline

Here is my script. Im trying to set up variables in pipline shell script: node { anyconnect = docker.image('anyconnect:1').run("--cap-add NET_ADMIN --cap-add SYS_ADMIN --device /dev/net/tun:/dev/...
0
votes
2answers
41 views

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 ...
0
votes
1answer
59 views

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 ...