Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

Filter by
Sorted by
Tagged with
1
vote
1answer
15 views

How to post logs to Cloudwatch with CLI?

Im tring to create a bash script that checks the status of the website, Im using this command: This one to create the logstream aws logs create-log-stream --log-group-name "WebsiteStatusMessage" --...
0
votes
0answers
4 views

Can't get cron to output a GUI message / how to make user aware cron is being executed

I need to run, on Ubuntu 18.04, via cron a script, myscript.sh that I want, among other things, to display to the user a message when it is being run so that he is aware that cron is being run (...
1
vote
1answer
49 views

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

a shell script that shuts down all processes launched by a particular user in the last x hours [duplicate]

I need a shell script that shuts down all processes launched by a particular user in the last x hours. I tried this: HOUR=$2 curenttime=$(date + %s) for pid in $( ps -u "$USER" -o pid) do
0
votes
0answers
15 views

Removing contents separated with line separator by searching a pattern

I have a file containing below output. ---------- ID: alternatives_create_editor Function: alternatives.install Name: editor Result: None Comment: Alternative will be ...
0
votes
0answers
74 views

Jibri server with AWS autoscaling

We configured jibri server for recording meetings through Jitsi meet. We should handle more number of recording in parallel so we configured Jibri server in auto scaling mode. As per the CPU threshold ...
0
votes
1answer
22 views

Shell Script to kill long running PIDs

I was hoping someone could answer a question regarding this shell script that I've just gotten while taking over a website previously owned by someone else. This was their backup fix to catch any long ...
0
votes
0answers
29 views

Trying to get SSH output from within a for loop in a script

I'm trying to SSH into a bunch of hosts in order, and run a command to get a list of users on each one. Outside of a for loop, the output shows up just fine one-by-one. Inside a for loop, it ...
0
votes
1answer
21 views

Wich Shebang should you use in a shell sript?

Sorry, this is maybe a stupid question, but I am new to shell scripts. I have a file called oem-device-name.sh. I need to execute an external check for Zabbix: https://www.zabbix.com/documentation/5....
0
votes
0answers
17 views

Linux SSH to act like Plink.exe with the same script

I hope I can explain this properly, and I hope I've placed this in the proper forum and category. My goal is to move a XAMPP server to a LAMP server. We'll call these servers "Xray" and "Lima," ...
0
votes
0answers
37 views

In shell script, spawn command not found

Spawn command not found. Earlier I have used the spawn command in shell script. Now I'm not getting the package name which needs to install for spawn command.
2
votes
1answer
16 views

Bash - Math: Returns integer instead of float

Bash returns value 4 instead of 4.2 when dividing 21/5. And returns 36 when doing 9 * (21/5) instead of 37.8. echo "$(( 21/5 ))" 4 echo "21/5" | bc 4 Similarly ( 9 * ( 21/5 ) ) returns 36 but it ...
2
votes
1answer
22 views

How can we limit and give space in after each special character in bash script output?

I have to send all rpm related information to our log analyzer and I am running the command below which give continuous output as follows: CMD sudo rpm -qa --info | egrep 'Name|Version|Architecture|...
1
vote
1answer
24 views

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

recursively convert files and leave in source directory

I'm using the following command to recursively convert MP4 to PNG. The command functions recursively - (converts file and leaves converted file in the source directory) although it results in the ...
0
votes
2answers
80 views

Run a multiline bash script piped from stdin

I'm looking for a simple way to include multi-line scripts inline in documentation to make it transparent what each step does. This works echo "echo 1234" | bash So does this echo 'for N in 1 2 3; ...
0
votes
1answer
66 views

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

Parallelize curl requests

This is my shell script: for i in `seq 1 $1`; do filename=randomfile$(uuidgen).txt head -c $2 </dev/urandom > $filename checksum256=$(sha256sum $filename | awk '{ print $1 }') ...
1
vote
2answers
401 views

my bash scripts are not working when called through supervisord

I'm using the following systems: Ubuntu 18.04.2 LTS bash 4.4.19(1)-release supervisord 3.3.1-1.1 I have written two scripts that work pretty well from the CLI, but when I try to use supervisord ...
-1
votes
2answers
31 views

Backup of multiple sites on Ubuntu

I have multiple sites in my /var/www/html/ folder like following:- /var/www/html/site-1 /var/www/html/site-2 /var/www/html/site-3 /var/www/html/site-4 i want to zip each site on my server and to ...
-1
votes
1answer
60 views

Make shure that if an error ocurrs the script start again

I have this bash script that runs 2 python scripts in parallel, they bring data from another server via API, they work fine, but sometimes errors ocurrs when connection problems exists, and only ...
0
votes
0answers
22 views

High CPU utilization from a script [duplicate]

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

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 '/...
-1
votes
1answer
300 views

what is the right approach to purge /var/spool/abrt/

We want to automate the process of removing old directories from /var/spool/abrt/. We have RHEL machines - version 7.x. The known way is to do the following # systemctl stop abrtd # systemctl stop ...
0
votes
1answer
46 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
20 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
2k 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
71 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
265 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
45 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
273 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
110 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
34 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
17 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
25 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
211 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
88 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
77 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
401 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
94 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
49 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
52 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
79 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
62 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
99 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
73 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
639 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
427 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
54 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) ...

1
2 3 4 5
11