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

Bash linux increment variable

i am trying to increment a variable name inside a for loop to get 4 dynamic variable in each loop, this is an example while read line do for n in `seq 1 4` do vr$n=$(echo -e "$line" | awk '{print $'$n'}') …
0
votes
1 answer

Bash FTP login into Microsoft FTP Service, Invalid command

This is my script. As you can see it executes only 1 command (cd /) after connecting to a remote FTP server. It's very simple... but it doesn't work and give me "Invalid command". I don't understand why. #!/bin/bash HOST=xxx #This is…
Mich Dart
  • 121
  • 2
  • 6
0
votes
2 answers

Bash scripting: Using wildcard

I have two different folders. The first one contains symlbolic links named with the names of my servers (for example: udcedpai101). The second one contains the inventory of my servers where the files are named with the server name at the beginning…
Stoupsi
  • 1
  • 1
  • 3
0
votes
2 answers

using powershell ; from a given location a of folder i want to validate and show the number of specific filetypes respective folder

Using powershell from a given location a of folder I want to validate and show the number of specific filetypes respective folder. I tried using the command to count the number of files in a folder I am able to get total count of files avaiable in…
0
votes
1 answer

Why is my shell command not working?

I have a shell script that I'm working on that uses pssh to get the user id of a user on a remote server: for USER in $(cat users.txt); do runuser -l mike -c 'pssh -H server.mike.com -o /home/mike/output id -u $USER' cat…
Mike
  • 311
  • 2
  • 5
  • 15
0
votes
1 answer

Issue with Bash Script On FreeBSD

I have the below bash script set to run every hour via cron as the root user. The purpose of this script is to email us when files have been uploaded to our sftp server and send us the logins. Here is the script build_report() { # This…
0
votes
1 answer

How to automate input for a repetitive script! Expect in Bash?

I am a junior sys admin. Reason I'm asking this question is because we don't have a senior sys-admin here who is proficient with scripting. Senior guys are at the head office and too busy for something like this. My scenario is this. I have to run a…
2legit2quit
  • 171
  • 1
  • 2
  • 10
0
votes
1 answer

Executing command remotely on another linux server from a shell script

I have a shell-script which extract details from a log file between two dates and executes a command on the output to generate some report.The log files are on different server and scripts are executed on different server. the Script looks like : …
anand
  • 152
  • 6
0
votes
1 answer

Command fails during script execution in bash

I'm working on a bash script for automatize some common tasks but I'm having some issues and I need some help. This is the script I'm talking about: #!/usr/bin/env bash PS3='Please enter your choice: ' options=("Prepare environment" "Create new…
ReynierPM
  • 710
  • 5
  • 14
  • 30
0
votes
1 answer

Creating enterprise init script (to support all Linux distros)

I'd like to create my own init script to make my program start at boot and be controlled via "service" utility in most popular Linux distributions. Requirements: it should be portable across different distros(it should support at least…
guZ
  • 1
  • 1
0
votes
3 answers

How can a script loop for 30 days?

I have a script, backup.sh, that creates a backup of a MySQL database and then SCPs it to a remote server. This works great, and I can run this once per day using crontab with no problems. However, I want to only store the last 30 days of backups,…
mikemike
  • 131
  • 4
0
votes
2 answers

Creating a log file inside a script works when manually run, but not when run through cron

I'm using Percona's Xtrabackup tools to back up a database nightly. I wrote a wrapper script to keep the proper number of backups around, write the output to a log file, and email the log file if the backup dies. When I manually run the script as…
Josh H
  • 19
  • 6
0
votes
1 answer

124 emails sent at once while one should be sent every five minutes by cron if a certain web service stops running

So I set up a simple script to send an email alert when a certain web service stops running. It has a simple flow of: test = $( curl [address] | grep [a certain string in response] | wc -l ) if [ $test -ne 1 ]; then echo "there has been an…
Reuben L.
  • 111
  • 1
  • 7
0
votes
1 answer

Why is permission denied during pssh?

I am trying to add an ssh public key to a bunch of servers authorized_keys file. My thought was to use pssh and a list of hosts. To test, I tried to pssh to one host: pssh -i -H root@host echo mypublickeyasastring >> /root/.ssh/authorized_keys When…
Mike
  • 311
  • 2
  • 5
  • 15
0
votes
1 answer

Bash Script - Expect does not send password that ends with $!. Also need improvement to report connection timed out

Update: Password issue is fixed and connection timed out message was fixed too. Adding \ before $! worked. Example: *password\$! set passwds { *password\$! @tempP@ss %Test4%} For connection timed out, added the below code after "s password:"…
ajsdg
  • 131
  • 1
  • 1
  • 6