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

How to run mysql commands through shell script?

mysql -u root -pmysql; SELECT TABLE_NAME AS "Table Name", table_rows AS "Quant of Rows", ROUND((data_length + index_length)/1024/1024,2) AS "Total Size Mb" FROM information_schema.TABLES WHERE…
krunal shah
  • 335
  • 1
  • 3
  • 13
1
vote
2 answers

delete string recursively from all index.php files in a home folder

We need a shell script to find and replace a piece of injected code within all index.php files within a /home folder
euan
  • 11
  • 1
1
vote
6 answers

want user will logout from shell on exit of bash script

I want, when a linux user exits from a shell script, that it also logs out from the bash shell. Is this possible?
user56285
1
vote
2 answers

Need script to redirect STDIN & STDOUT to named pipes

I have an app that launches an authentication helper (my script) and uses STDIN/STDOUT to communicate. I want to re-direct STDIN and STDOUT from this script to two named pipes for interaction with another program. E.g.: SCRIPT_STDIN >…
davidparks21
  • 928
  • 1
  • 12
  • 27
1
vote
1 answer

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 "ssh-copy-id" done to a user "backup" that can only…
1
vote
1 answer

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 testing, I cannot change to a directory with…
SimoneM
  • 121
  • 1
1
vote
0 answers

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 servers based on which server is currently set as…
1
vote
1 answer

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 login to the instance just fine. I can then reboot…
Utkonos
  • 416
  • 4
  • 15
1
vote
1 answer

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 VolumeName : I am having a few queries: 1: I want every…
Newb_969
  • 21
  • 1
1
vote
1 answer

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 : echo password | sudo -S Command but it's not…
1
vote
1 answer

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 this security group. I have something done,but…
rikorey
  • 15
  • 1
  • 4
1
vote
1 answer

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 for "Add-Computer" runs before read-host or it's…
1
vote
1 answer

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 would like store db name, user name, password, etc. In…
Maxime
  • 69
  • 7
1
vote
0 answers

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 PowerShell. Please keep in mind this is a…
Darius
  • 11
  • 1
1
vote
2 answers

Why does `ps -x | grep foo` include the grep command?

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 example, in this contrived example, I see several…
jhericks
  • 113
  • 5