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
12
votes
5 answers

Can a shell script wait for a file to change and take action?

I wonder if I can write a script that will monitor for a change in a file and execute some action when the change is detected. Detailed explanation: OpenVPN writes its status to a file every 1 minute. I need to parse this status file and take…
davidparks21
  • 928
  • 1
  • 12
  • 27
11
votes
3 answers

Powershell Parameters

I have a Param block in my script Param ( [Parameter(Mandatory=$True)] [string]$FileLocation, [Parameter(Mandatory=$True)] [string]$password = Read-Host "Type the password you would like to set all the users to"…
TechGuyTJ
  • 792
  • 1
  • 13
  • 26
11
votes
2 answers

Can I change the ownership of all the files of a specific user?

Is there a way to recursively find all files owned by a user and change them to another user/group in Gnu/Linux? I assume there must be some magic one liner but my command line wizardry skills are not up to that :) Thanks!
john
  • 1,025
  • 3
  • 9
  • 15
11
votes
5 answers

Silent and scripted install of CPAN and Perl modules?

I need to install CPAN and some Perl modules automatically in a Scientific Linux (RHEL) installation script. Unfortunately the specific modules I want (at least one of them) cannot be found as RPM:s as far as I've seen. So I need to install CPAN,…
Mikael Grönfelt
  • 677
  • 3
  • 7
  • 14
10
votes
4 answers

How can I use openssl to get results from HTTP GET requests?

I need to use openssl to perform some HTTP GET requests in a shell script. The line I'm using to do this right now is shown below. This is parsing the content of an XML response of the following…
conorgriffin
  • 459
  • 1
  • 6
  • 25
9
votes
4 answers

control a bash script with variables from an external file

I would like to control a bash script like this: #!/bin/sh USER1=_parsefromfile_ HOST1=_parsefromfile_ PW1=_parsefromfile_ USER2=_parsefromfile_ HOST2=_parsefromfile_ PW2=_parsefromfile_ imapsync \ --buffersize 8192000 --nosyncacls --subscribe…
perler
  • 531
  • 2
  • 6
  • 10
8
votes
4 answers

Loop through servers and run command

I have a set of servers mentioned in a text file called network_list.txt . How can i run through the servers and run command and display the result ? I have tried the follows : filename="network_list.txt" service=httpd while read -r line do …
KTM
  • 213
  • 2
  • 6
8
votes
5 answers

Run a script from anywhere

I have a script: #!/bin/bash echo "$(dirname $(readlink -e $1))/$(basename $1)" that sits here: /home/myuser/bin/abspath.sh which has execute permissions. If I run echo $PATH I get the following:…
Cheetah
  • 241
  • 3
  • 8
8
votes
3 answers

How to run a script automatically on system startup in centos

I've successfully installed TeamCity ib CentOS 6.2 Minimal. I'm stuck on trying to run a script automatically on system startup: /opt/TeamCity/bin/teamcity-server.sh start I've googled around and tried various methods all of which seems to fail. …
atp03
  • 209
  • 1
  • 2
  • 5
8
votes
3 answers

"watch" command to notify on newly created files on linux

watch command to notify on newly created files on linux How to modify the below command to notify on creating a new file to /usr/local/mydir/ by linux user john ? watch -d 'ls -l /usr/local/mydir/ | fgrep john' ie I want to continually monitor and…
Aha
  • 409
  • 3
  • 8
  • 18
8
votes
3 answers

From a shell script, how can I check whether a table in MySQL database exists or not?

I am trying to write a script which allows a user to select the what manipulation he needs to do on a table. I want to check if the table exists or not. If it exists I will continue the other things or else I exit saying table doesn't exist. How…
RathanKalluri
  • 81
  • 1
  • 1
  • 2
8
votes
1 answer

using temporary files vs pipes advantages and disadvantages

Say I have a file named jobs.csv and I would like to get the top 50k jobs done by Foo I can either do: # cat jobs.csv | sort -u | head -n 50000 > /tmp/jobs.csv # cat /tmp/jobs.csv | while read line; do Foo --job=$line; done Or # cat jobs.csv | sort…
Tzury Bar Yochay
  • 727
  • 11
  • 24
7
votes
2 answers

Shell script for docker ps -a | grep to find number of certain containers running

I want to write a script that is executed by my development build server that will remove any 'similar' docker containers before building and running a new container. Below is pseudo code for the bash script I need var name = $1 var…
TheJediCowboy
  • 613
  • 3
  • 8
  • 12
7
votes
3 answers

Echo each shell script command with a timestamp

set -x or set -v prints every executed command. How do I get the command printed with the time when the command started executing?
warvariuc
  • 358
  • 1
  • 5
  • 14
7
votes
2 answers

expect script + expect miss the send string + delay issue

I write the active.ksh script (based on expect) in order to login automatically to some Solaris machine and execute the hostname command (login to virtual IP in order to verify which hostname is the active machine - I have two cluster solaris…
Eytan
  • 611
  • 6
  • 13
  • 27
1
2
3
41 42