Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

Filter by
Sorted by
Tagged with
-11
votes
0answers
30 views

I need write a shell script perform [closed]

Prompt the user for an account name Search /etc/passwd for the user account If the account exists return the following information UID and Home Directory (You'll have to use some commands from earlier ...
0
votes
1answer
55 views

On CentOS 8 in profile.d do I need to add my script related to environment variables to both an .sh and .csh file?

I need to add environmental variables related to proxy servers to allow my node.js app to communicate with reCAPTCHA Enterprise on Google Cloud. When I run the scripts from Accessing Google Cloud APIs ...
0
votes
0answers
30 views

Issues with Bash Script to SSH and Copy String Variables from a CSV to a remote file

Here is my script #!/bin/bash clear PSQLSTART="INSERT INTO TABLE (Name, Description, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12, Field13, Field14, Field15,...
0
votes
0answers
26 views

Using setuid in a Shell Script on Ubuntu 20.04

So I have a Laravel PHP app on Nginx on Ubuntu 20.04. I have a simple deploy.sh script that will: Put Laravel into maintenance mode, so it returns a 503 error if anyone visits the site Pulls down the ...
0
votes
1answer
68 views

Jenkins vs shell scripts

why would Jenkins get a different result from shell scripts(redhat 7) alone? I have shell scripts that run fine if I execute them from a terminal, however when I run the scripts from Jenkins they get ...
0
votes
2answers
60 views

Best and simple way to prevent automatic backups filling all disk space in Linux, before it actually happens

Which do you think is the best and most simple way to prevent automatic backups filling all disk space in Linux, before it actually happens? I would like to automatically recycle the oldest ones when ...
1
vote
2answers
67 views

Bash script - check if a variable is located between 2 others variables?

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 "...
0
votes
1answer
52 views

Monitor Docker Container for No Output

I have a long running process in a docker container that is setup like this: Dockerfile ... ENTRYPOINT ["./invoke.sh"] invoke.sh #!/bin/bash ./long-running-command If long-running-command ...
0
votes
1answer
68 views

Diff says file does not exists – why?

I transfer a file from a remote server to my local server. If this is done I do a diff to check if both files are identical to check if the transfer was successful. So I do this: ssh -o ...
2
votes
2answers
159 views

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: # ...
1
vote
1answer
31 views

Run xterm script from /etc/profile leads to “cannot load font”

I want to auto-start a shell script and therefore I added this line to my /etc/profile: /bin/su -c "/path/to/my/script" user - the script itself starts a xterm shell command and output ...
0
votes
1answer
19 views

COMMAND TO DISPLAY SPECIFIC LINES IN A SCRIPT [closed]

I have a script containing 5 lines in it. what is the command to view only 1st and last line in the script in one single expression.
0
votes
0answers
40 views

How do I get the Current time in milliSeconds in a Shell script in buildroot environment?

MYENV=$(date +"%s%N") printf "Time:: %s\n" "$MYENV" or MYENV1=$(date +"%T%N") printf "Time:: %s\n" "$MYENV1" I tried above methods, they ...
0
votes
2answers
58 views

Bash script to create variables from and run commands on each item in an external list

On my local machine I have a text file containing a list of IP addresses and directory names. list.txt # Comment for Server 1 XXX.XX.XXX.X DIRECTORY-NAME # Comment for Server 2 XXX.XX.XXX.X DIRECTORY-...
1
vote
3answers
896 views

Using if else statement inside shell module in ansible playbook

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

Update crontab of my web user using “sudo”

I need to update the crontab of my web user (the user that is executing all websites). In my crontab I'm using shell script with commands that needs to use "sudo". The script is well ...
0
votes
0answers
37 views

Find volume id in AWS ubuntu linux

I'm trying to find volume id in ubuntu linux using AWS CLI, I have written below command aws ec2 describe-volumes --region us-east-1 --filters Name=attachment.instance-id,Values=i-0b0df4542545f8a Name=...
-1
votes
1answer
56 views

Can somebody help me on how to zip these individual log files within while loop

I am able to break o/p of a big logfile (filename.log) into individual log files of 1 min each (filename.log.140108) using while loop, but I want these files to be saved as zip files due to capacity ...
1
vote
1answer
95 views

How to calculate CPU and memory utilization on solaris box

I am trying to write shell script to calculate memory and cpu utilization on solaris box. For CPU utilization, I tried below command but I want to append date, time and host name in same command but ...
0
votes
0answers
51 views

Automate OpenSSL CMS with PKCS11

I'm using OpenSSL CMS with a PKCS11 engine to sign a file. At the moment I have to manually register a PKCS11 engine: engine dynamic -pre SO_PATH:./libpkcs11.dll -pre ID:pkcs11 -pre LIST_ADD:1 -pre ...
0
votes
1answer
49 views

Copying Content from a file to another when a new line is added using poweshell script

I have a file named server1.txt and one more file named server1_copy.txt. In server1.txt, all logs will be added from the application. So whenever a new line is added in the server1.txt, we need to ...
0
votes
1answer
60 views

how to run a bash backup script with simultaneous processes without getting stuck with infinite looping?

I wrote this script for run postgresql pg_dump of multiples schemas. Since it takes much time to finishes all i'd improved it by running simultaneous dumps with this: for SCHEMA in $SCH do while [ $(...
0
votes
2answers
95 views

A shell script to ssh, watch log file, and run command

I want a shell script that connects to a server via ssh, starts watching a log, and then touches a file. It's important that I do them in that order, because I want to see in the log the effects of ...
0
votes
0answers
118 views

Powershell script to delete oldest files

I DO NOT want to "delete files older than X days." If I wanted to do this, I'd just pick one of the thousands of scripts out there that have already been written for that purpose, and I ...
0
votes
1answer
36 views

su - with automatic change directory once su command is done in shell scripting

im not familiar in shell scripting but im trying to achieve at least this script but my problem is once superuser rt is done logging in it brings me to this [rt@superuser root]$ instead of reading ...
0
votes
0answers
12 views

cisco firepower connection events to be captured and store in linux file

I need to capture cisco connection events in the Linux file which will help to analyze connection events per source IP and destination IP. If the file will be store in the Linux server then ...
0
votes
0answers
40 views

lftp sync FXP script

since I have two ftp servers, I would like to make sure that the first server (ftp1) automatically synchronizes with the (ftp2) the files. I have read that it is possible to do this with lftp via the ...
0
votes
1answer
50 views

Trim and allign an output of command in expect script

{ echo ' ' ;echo ' IP : ' ;ip route get 8.8.8.8 | cut -d' ' -f7,8 | tr -d 'src' ;echo ' ' ;dmidecode -t bios | grep -iw 'Version' ;echo ' ' ;} the output of above command mentioned is: IP : 10.0.0.1 ...
0
votes
2answers
60 views

saving sql dump error in a file

I want to save error if error comes, into a file. But error not redirecting into file. I get below error and its not redirecting into file. mysqldump: Couldn't execute 'SHOW FIELDS FROM `v_comloc`': ...
1
vote
1answer
959 views

I'm not good at scripting…How best can I update the IP address on a debian server running live from PXE (DHCP reservations are not an option) [closed]

This is more a brain dump than anything at this point, but I'm stuck and help would be appreciated! I have a really complicated set of limitations on 3 of my servers that necessitated running the OS ...
0
votes
0answers
25 views

Kerberos cpw ignoring password policies

I'm trying to integrate an implementation of an LDAP user interface with the ability to change Kerberos user password. I'm using a non-interactive command for this task: kadmin -k -t $KEYTABLOCATION -...
0
votes
1answer
262 views

Case statement not working properly in shell script [closed]

The case statement in the bash script does not work. Below is the snippet of my shell script. usage="Usage: \n servicer [ service argument ] {-h}\n" invalid="\n not a valid option\n&...
0
votes
1answer
67 views

Parsing Command Response in Bash Script

I need a bash script that takes the output of a shell command and parses that output to pull out the state. If the State is: Bad, an email should be sent. ~$ bucardo status PID of Bucardo MCP: 2074 ...
0
votes
0answers
13 views

puppet master configurartion with automatically capture vm IP in puppet configuration

i am trying to install puppet master with automation on vm, I am using shell scripting for this but i am entering IP address of puppet master vm in puppet configuration. but i need to update the IP ...
0
votes
1answer
900 views

Systemd: Unit-file timeout after start

I have written a bashscript with the following content: #!/bin/bash cd /opt/ut_server/System ./ucc-bin-linux-amd64 server DM-Rankin?game=XGame.xDeathMatch?mutator=AntiTCC2009r6.MutAntiTCCFinal,...
0
votes
0answers
19 views

Extract attchment from /var/spool/mail/root

Following an incident, my sendmail rejected all the mail and send the undelivered status with the error message on /var/spool/mail/root. There are hundreds of mail. As the incident is closed, I would ...
1
vote
2answers
591 views

How to delete docker images older than x days from docker hub using a shell script

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 ...
1
vote
2answers
598 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
2answers
306 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
56 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 ...
0
votes
0answers
579 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
26 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
206 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
29 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....
2
votes
1answer
67 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 ) ...
2
votes
1answer
25 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
55 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
2answers
843 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
481 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
656 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
2 3 4 5
12