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
2
votes
4 answers

How to lock user in a shell script program?

Let's say I have a Linux OS without desktop environment. After the PC finish boot up, it will directly show the shell terminal to the user. I plan to write a shell script program and make it automatically start everytime after the PC finish boot up,…
kwc1
2
votes
0 answers

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 file as: <164>2023-02-22T09:34:24.337Z test_host…
Cool Guy
  • 21
  • 1
2
votes
2 answers

Can't access instance after setting up iptables rules

I'm trying to setup some rules to block all ports except 21 and 22 on TCP (SSH and FTP). But when I try to run this script I get locked out of my instance and can't access it. This is the script: # Flush the FW Rules iptables -F iptables -X #…
mj01100011
  • 23
  • 3
2
votes
4 answers

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" --log-stream-name $timestamp This other one to post…
2
votes
1 answer

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 should be 37.8; y = 9; num_lines = 21; w = 5; let…
Robert
  • 23
  • 2
1
vote
2 answers

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 with them, they don't work. When I execute them by…
1
vote
1 answer

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…
xendi
  • 414
  • 5
  • 10
  • 22
1
vote
1 answer

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 /etc/cron.daily. Where do I define the environment…
1
vote
2 answers

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 using nvme volumes. This because the output of file…
berimbolo
  • 113
  • 4
1
vote
2 answers

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 all of the files that start with 00 so they start…
DavevaD
  • 23
  • 6
1
vote
3 answers

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 datagrams dropped due to errors …
Tim Luka
  • 147
  • 2
  • 8
1
vote
1 answer

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 --init --recursive if [ -f composer.json ]; then …
user3360140
  • 281
  • 1
  • 4
  • 14
1
vote
1 answer

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 NAME="CentOS Linux" VERSION="7…
wandermonk
  • 103
  • 12
1
vote
2 answers

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 output text file, I wasn't getting any output. …
efw
  • 111
  • 2
1
vote
1 answer

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.245.65 /bin/false I want to add an ip in the end…
user482363