Skip to main content

Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

0 votes
0 answers
25 views

see below details eccdbpvm02:/mnt/HANA/E1P/backup/data/DB_F1P # crontab -l 05 00 * * * /usr/sys_scripts/clear_log >> /usr/sys_scripts/log.txt 2>&1 eccdbpvm02:/mnt/HANA/E1P/backup/data/...
Henokert Del Rosario's user avatar
192 votes
8 answers
440k views

sleep is a very popular command and we can start sleep from 1 second: # wait one second please sleep 1 but what the alternative if I need to wait only 0.1 second or between 0.1 to 1 second ? remark: ...
yael's user avatar
  • 2,583
1 vote
2 answers
825 views

I a bash script, I want to obtain the global IPv6 address of my machine for a given network adapter (on my case 'ens18'). To get started, I issued the following command: ip -6 addr This gives me the ...
Boris's user avatar
  • 113
1 vote
1 answer
122 views

I have a couple of custom scripts to help me with more or less regular tasks; and recently decided to move them from /usr/bin to ~/bin to have a better overview. I also added home/myusername/bin to $...
Titus's user avatar
  • 271
0 votes
1 answer
108 views

I'm trying to write a script that will read search strings from an input file and then execute a command with $string in the middle of the command line. This is an example of the working command line:...
Drew's user avatar
  • 101
0 votes
0 answers
129 views

I have a containerised command I'd like to run: docker run my_docker_image. Rather than install the command's dependencies into the main computer, I'm packaging them all into an image, that then users ...
Rob Grant's user avatar
  • 103
0 votes
1 answer
60 views

I have an HTTP server (source code not accessible and cannot be substituted at this time) running on my Linux machine, which can be configured to execute any commands on requested. However, the HTTP ...
Gamcheong's user avatar
53 votes
7 answers
60k views

Usually, I run aptitude -y install locales then dpkg-reconfigure locales to set up locale. Now I want to put it into a shell script, how can I reliably do the following, automatically / non-...
kenn's user avatar
  • 745
7 votes
4 answers
5k views

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
  • 33.8k
0 votes
1 answer
152 views

When I run command bellow in bash shell : if [[ $(readonly | cut -d= -f1 | grep -qo HISTFILE && echo $?) == 0 ]]; then sudo grep -iwo "readonly HISTFILE" /etc/profile /etc/profile.d/*...
M. Fachrizal Utama's user avatar
2 votes
1 answer
4k views

I have a shell script that runs on a FreeBSD machine. The script has some commands that needs superuser privileges. I’m executing the script remotely and it’s skipping the sudo’d commands. I tried the ...
ossama assaghir's user avatar
28 votes
9 answers
60k views

I'm trying to create a shell script that, among other things, starts up ssh-agent and adds a private key to the agent. Example: #!/bin/bash # ... ssh-agent $SHELL ssh-add /path/to/key # ... The ...
Dan's user avatar
  • 717
0 votes
1 answer
7k views

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
  • 11
1 vote
0 answers
147 views

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
  • 45
0 votes
1 answer
1k views

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

code : subject="mail subject" body="Hello World" from="[email protected]" to="[email protected]" echo -e "Subject:${subject}\n${body}" | sendmail -f "...
Nitin Alety's user avatar
1 vote
2 answers
1k views

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 "...
Maxime's user avatar
  • 79
0 votes
3 answers
7k views

The first 3 variables will always have no spaces. The fourth "slacksitename" has spaces ip=“x.x.x.x" record_name=“demo.xyz" slackuri:”WEBHOOK" slacksitename:”123 Main St" ...
northport's user avatar
0 votes
1 answer
4k views

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
  • 259
0 votes
1 answer
421 views

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

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
891 views

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
20 votes
2 answers
9k views

In an existing shell script, I'm seeing some variables referenced that either include or end with a minus sign. For example: PID=${PID-/run/unicorn.pid} and: run_by_init() { ([ "${previous-}" ] ...
Matt Huggins's user avatar
1 vote
1 answer
10k views

I have a VM that has the fixed snapshot, and I have not the right to install anything How I can achieve the goal? Passing password to ssh connection Windows 10, using git bash without needing to ...
Nusrat Nuriyev's user avatar
-1 votes
1 answer
712 views

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
  • 264
-1 votes
1 answer
260 views

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
986 views

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

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

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

Good morning, I have a custom software that updates with a custom script.sh. Part of the file goes something like this: if [[ $software == A ]] then echo "downloading package..." ...
Perovic 's user avatar
1 vote
1 answer
605 views

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
20 votes
7 answers
38k views

I'm currently using rsync on a script that deploys a PHP application from a staging to a production server. Here is how: rsync -rzai --progress --stats --ignore-times --checksum /tmp/app_export/ root@...
Mauro's user avatar
  • 396
9 votes
3 answers
7k views

How to delete docker images from docker hub using a shell script. I want to delete all images from docker hub older than past 50 days of a private docker hub account. Any ideas? Which tools to use ...
amit's user avatar
  • 131
2 votes
0 answers
327 views

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

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

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

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
  • 79
36 votes
2 answers
49k views

I've got a script which uses openssl's s_client command to pull certificates for a big set of hosts. Some of these hosts will inevitably be unreachable because of a firewall. Is it possible to set ...
Justin Ainsworth's user avatar
0 votes
1 answer
100 views

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

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
1 vote
2 answers
3k views

I know that it does (often) include the grep process and I know adding | grep -v grep or grepping on [f]oo instead will prevent it, but my question is more about order of operations I guess. For ...
jhericks's user avatar
  • 113
2 votes
4 answers
6k views

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" --...
sysalam0's user avatar
0 votes
1 answer
659 views

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

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
2 answers
58 views

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
0 answers
838 views

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

I am trying to run if else statement inside shell module in ansible playbook but looks like my else statement is not executing in any case. - name: verify application/database processes are not ...
user600994's user avatar
0 votes
1 answer
2k views

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
0 votes
1 answer
2k views

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
2 answers
968 views

I want to start screen and put a couple of programs running inside on startup. I've seen many similar posts but none answered my question. so I put in rc.local following 2 lines: screen -dmS scr ...
DenisZ's user avatar
  • 148

1
2 3 4 5
13