Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

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

What is the correct way to check monit status/summary success/failure

I have monit utility on production for monitoring several daemons (our micro-services). I'm trying to figure the best way to unmonitor/monitor my daemons while updating them. So, basically I need ...
Alexander Bell's user avatar
-1 votes
1 answer
31 views

Extract Pages from Various PDF Files into New PDF File [closed]

From a.pdf, I would like pages 2 and 5 b.pdf, pages 3 and 4 c.pdf, pages 7, 8, and 9 copied into a new PDF file. All input pdf files are ten pages long. I'm using bash, and plan to make many ...
lmat - Reinstate Monica's user avatar
0 votes
2 answers
26 views

trying to see if how many times service Accounts was logged in [closed]

Hi I am new to shell scripting ,I am trying to see how many times an accounts were logged in the log file. If an account was logged in more than 20 time I need the name of those accounts to be printed....
NJN's user avatar
  • 1
0 votes
1 answer
107 views

Unable to List Contents or Create Files in /var/tmp Folder from PHP Executed Bash Script

Objective: I want to trigger a webhook on a private linux-machine (its a local system not connected to internet), which can delete the spool data generated by CUPS server in /var/tmp folder. To ...
Sheikh Muhammed Tadeeb's user avatar
0 votes
1 answer
60 views

time nohup ./script --> the time hasn't been logged [closed]

I need to measure the time that Firefox takes to build itself from the source code. Here's what I do normaly: nohup ./mach build > my_log.log & I then prepended time to it: time nohup ./mach ...
Kentuk's user avatar
  • 1
-1 votes
1 answer
45 views

Copy/Move Entire Line To End Of The Line Above

I have a file that looks like the following: /path/to/a/very/long/path 0 0 0 0 0 0 I need to move the line starting with a number (this can be any value not necessarily 0) to the end of the ...
djc72uk's user avatar
  • 33
1 vote
1 answer
68 views

Hardening the security of a backup shell script of a web-server with mysql database

In the case of a simple web-server with a MySQL database, the script has to dump the database, copy the web-server files and tar everything together. Then a NAS server Rsync the tar file via a "...
Danilo Steps's user avatar
0 votes
0 answers
38 views

How to avoid duplicate entries in DNS Bind cache db file?

While running command "rndc dumpdb -cache" it has huge amount of data some duplicate entries like one domain has multiple entries with same target but different TTL, how to reduce like ...
Sha's user avatar
  • 1
0 votes
1 answer
36 views

Change Ubuntu server password every 7 days and do autologin

am working on a scenario where i need to Change Ubuntu server password every 7 days and do autologin. i tried with breaking the problem: command to create user with password: useradd -p $(openssl ...
user9990's user avatar
0 votes
2 answers
89 views

Best Path for nginx Files [closed]

I've always struggled with various paths for nginx files and where they should be positioned. As we know, we can change where we can park both the www directories for our web app, as well as the ...
Rich_F's user avatar
  • 125
2 votes
0 answers
111 views

How to enable logging of commands run through shell script in ESXi Hypervisor?

On ESXi Hypervisor, If I run a command on the terminal via SSH, the commands are logged in the shell.log file, i.e if i run this command [root@esxi04:~] ls -la then I can see this command in shell.log ...
Cool Guy's user avatar
0 votes
1 answer
352 views

Bash loop through dates

I'm trying to copy data from psql via a bash script now I'm stuck with a loop my bash script is as following: #!/bin/bash DATEBEGIN=2016-03-01 DATEEND=2016-03-31 DATEMONTH=2016-03 echo "Copy ...
Sander Böhm's user avatar
0 votes
1 answer
2k views

Setup Apache Docker container to keep running after executing php shell CMD

I'm trying to run a Docker container based on: PHP 8.1 Apache 2.4 MariaDB (latest official docker image) Dockerfile: FROM php:8.1-apache WORKDIR /var/www/html/ RUN pecl install xdebug \ &&...
DevelJoe's user avatar
  • 187
0 votes
0 answers
54 views

GAWK not running in crontab

I have the below script running successfully manually. But when it is executed in crontab (below), I dont see anything happening. Script #!/usr/bin/gawk -f #!/bin/bash PATH=/usr/local/bin:/usr/bin #...
serverstackqns's user avatar
0 votes
0 answers
106 views

Initialization of Samba Active Directory in Podman fails

I have created a Samba Active Directory PDC that runs inside a Podman container. I was trying to working on how to restore the server from an offline backup, when I encountered something unexpected on ...
Lasse Michael Mølgaard's user avatar
0 votes
1 answer
91 views

Variable in AWK

How can I add a variable within awk command? below is my command: cat /home/ubuntu/test/copy.txt | awk 'NR==21{print ".host = "$line";"}1' $line is basically an IP address which ...
serverstackqns's user avatar
1 vote
1 answer
413 views

bash change directory with spaces and backslash

I'm trying to build a script that I need to be quite able to manage directory with spaces or/and backslashes in their name or not. Inside a bash script or directly on bash shell using variables for ...
SimoneM's user avatar
  • 121
1 vote
0 answers
64 views

Programmatically (SH Script) check which server is traffic routed too by HA Proxy

I have 2 HA Proxy servers with Keepalived configured with them, and have 2 backend servers to which traffic is routed by HA Proxy, am writing a shell script that will sync a directory between backend ...
MoonLight's user avatar
  • 111
1 vote
1 answer
34 views

Scripted Password Change Does Not Survive Reboot Unless One Login Occurs - Debian 11

I am trying to automatically set the root password to random characters via bash script. The script is part of a Vagrant shell provisioner. If the script runs the password change only, I am able to ...
Utkonos's user avatar
  • 416
1 vote
1 answer
275 views

Powershell Script to check free disk space on servers

I am in need to check free space on servers but I am getting more than enough details. DeviceID : C: DriveType : 3 ProviderName : FreeSpace : 76691152896 Size : 160482455552 ...
Newb_969's user avatar
0 votes
0 answers
48 views

Need help to Split the below HTML text file in two parts using linux scripting

I have a html main.txt file, I need help to split it in two parts. headpart.txt and bodypart.txt. Below is my html main.txt text file - Original <p class=\"auto-cursor-target\"><br /...
Goural's user avatar
  • 25
6 votes
4 answers
2k views

Robust way to resolve a DNS address in a script (IPv4 (A) and IPv6 (AAAA))?

I have a domain name in a bash variable ($TARGET), and I want to get the IPv4 (A record) address of it in my bash script (I also want to get the IPv6 AAAA record (if exists)), in a robust manner. i.e. ...
Amandasaurus's user avatar
  • 31.6k
1 vote
1 answer
2k views

Running Shell Script without a Password Prompt

I have a shell script that runs on a freebsd OS. the script has some commands that needs the sudo privileges Im excuting the script remotley and it's skipping the sudo commands i tried the following : ...
ossama assaghir's user avatar
1 vote
1 answer
3k views

How to automate aws cli commands with shell script

I wonder anyone can help me with making a shell script which automate aws cli process for: 1.Creating Security group 2.Set roles to this Security group port 22 and port 80 3.Create a ec2 instance with ...
rikorey's user avatar
  • 15
0 votes
1 answer
22 views

Remove bunch of disconnected LUNs by shell script (regex issue)

Have a problem with my script, don't want to run same procedure 200 times with changing LUN number. Remove the multipath device from ALL paths to the LUN, run echo 1 > /sys/bus/scsi/devices/${H:B:T:...
flexman's user avatar
0 votes
0 answers
159 views

Script for automating rsync between two machines (ssh, rsync, mysqldump involved)

I'm trying to create a bash script to automate a process that backups my WordPress blog (on a VPS) on my NAS. I always do it manually, but I'd like to just launch a command and let the thing do its ...
javipas's user avatar
  • 1,332
0 votes
0 answers
251 views

Can a bash script detect if it's **not** being run inside a `systemd` service?

I have a bash script. This script can be started as part of a systemd service (or transient systemd task with systemd-run). One can also run it stand alone. How can I see if “the current script” is ...
Amandasaurus's user avatar
  • 31.6k
1 vote
1 answer
236 views

Powershell script credentials prompt appears before read-host executes

I'm calling a script inside another script: ... ... powershell C:/temp/script2.ps1" ... ... That joins a VM to a domain after downloading some things. However, when the script runs, the prompt ...
rumplesmyboy's user avatar
-1 votes
1 answer
416 views

How to execute remote commands on linux and update return value?

As part of automation in gitlab ci. I am running a terraform template and creating a linux machine. After that, I need to run few commands on the remote machine. I am running those using the ssh ...
Kalel's user avatar
  • 234
1 vote
1 answer
2k views

bash script – MySQL commands and variables

I have a bash script who automate a Nextcloud server installation. To run MySQL commands I use the mysql -e command user@hostname:~$ mysql -e "CREATE DATABASE ‘NextcloudDataBaseName’" I ...
Maxime's user avatar
  • 69
0 votes
0 answers
72 views

Script to reassign floating IP address to my other machine running Ubuntu

I have a floating IP(X.X.X.191) assigned to the machine (Y.Y.Y.106) currently running ubuntu. Now I want the same floating IP to be assigned to my other droplet(Z.Z.Z.252). On digital ocean I can do ...
Himanshuman's user avatar
0 votes
0 answers
1k views

How to pass multiple arguments through ssh and use those arguments in the ssh script?

I have written one script on lets say server1 and from that script I want to execute script Start_UI_AdminApp.sh on server2 through ssh. I also need to pass the arguments while executing this ssh ...
Satish Lamak's user avatar
0 votes
1 answer
501 views

Shell script to check resolv.conf [closed]

I need to write a shell script which checks the contents of resolv.conf Eg domain example.com search abc.com abc.org abc.net nameserver 1.1.2.2 nameserver 3.3.4.4 abc.com/abc.org/abc.net can appear ...
Rajesh Yidi's user avatar
0 votes
0 answers
597 views

When calling script from jenkins it is not working as expected

we have one react application and start it using pm2 with pm2 start manually. We have written one script to run it, it is working as expected when we run script manually on server. But when calling ...
Satish Lamak's user avatar
0 votes
1 answer
86 views

Shell script not reading the file as expected

Below is the script trying to be executed: read n for ((i=1;i<=$n;i++)) do file=createserver"$i".json echo $file instanceid[$i-1]=$(jq -r '.instance.id' ./$file) echo $instanceid done $...
serverstackqns's user avatar
0 votes
1 answer
454 views

Variables on set-hostname and mv command in shell script

I have the below script in Shell: read n for ((i=1;i<=$n;i++)) do echo "Connecting to $publicip" ssh -i ./key.txt root@$publicip 'hostnamectl set-hostname autotest$i.domain.com && ...
serverstackqns's user avatar
0 votes
1 answer
590 views

Run commands that run in a shell as a script

Running the following commands in a shell runs without issues: ssh user@machine systemctl status my-service.service ssh user@machine sudo systemctl stop my-service.service scp -r ./my-service/* user@...
Ramon Smits's user avatar
0 votes
1 answer
75 views

Shell Script to Move a File Into Another User's Directory?

I'm running a Ubuntu 16.04 server. On my server, I have a file in directory /home/userA/dirA: userA@myUbuntu:~$ userA@myUbuntu:~$ pwd /home/userA userA@myUbuntu:~$ userA@myUbuntu:~$ ls -l total 8 ...
Pete's user avatar
  • 131
0 votes
1 answer
440 views

Using awk with column number in a bash script

I'm using a command like this to get some connections from nf_conntrack: awk '($3 == "tcp") && ($6 != "TIME_WAIT") && ($10 == "dport=1234")' /proc/net/...
ihorc's user avatar
  • 43
0 votes
1 answer
110 views

How monitor open files and kill its PID by shell script?

My system gets me an error that saying 'Too many open files'. I investigated this error and turned out that /usr/bin/uwsgi created sockets(?) more than 1020. If it creates more than 1020, I guess, the ...
deokyong song's user avatar
-3 votes
1 answer
56 views

Nested directories file restore

I recently took backup of one of my server's drive on AWS using one of the software and now at the time of restoring it i found out it took too long to restore as its having billions of files to ...
root's user avatar
  • 39
0 votes
1 answer
292 views

Automating GDB memory dumps [closed]

I'm trying to dump memory from a process on my Linux machine using GDB, but I'm trying to automate this using a script. So far I've been using the following commands (example): $ gdb --pid [pid] (gdb) ...
BungyStudios's user avatar
0 votes
0 answers
194 views

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 ...
Asem Abuelhija's user avatar
1 vote
0 answers
599 views

How to export the details of a digital certificate (.cer file) to a csv file using powershell?

I have a digital certificate that I'm using for a specific task. I need to export the details of the certificate such as the serial number and issuer to a csv file that is already on my computer using ...
Darius's user avatar
  • 11
-1 votes
1 answer
3k views

Handle exception with long paths in Powershell

I am new here and I facing issues with my powershell script whith long paths. This script aims to get relative path and hash from files/folders and its subfolders. It works with some with others I get ...
ed7's user avatar
  • 1
0 votes
1 answer
753 views

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 # ...
Maxime's user avatar
  • 69
0 votes
1 answer
1k views

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: ...
vik2595's user avatar
0 votes
1 answer
874 views

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/...
Zareh Kasparian's user avatar
0 votes
1 answer
336 views

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 ...
Alex's user avatar
  • 172
0 votes
1 answer
1k views

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 ...
kindleuptake's user avatar

1
2 3 4 5
13