Questions tagged [scripting]

A form of computer programming that — in the context of system administration — lends it self well to automating tasks.

A form of computer programming that — in the context of system administration — lends it self well to automating tasks.

Scripting is usually done in a scripting language. Such scripting languages are often dynamically typed and interpreted, as opposed to compiled languages. Examples of such languages include PowerShell, Perl and Bash.

1846 questions
47
votes
12 answers

How to find the gateway IP address in Linux

What command can you use to find the Gateway IP Address (ie. home router address) for eth0 in Linux? I need to get the IP address from a command line app to use in a shell script.
J. Polfer
  • 739
45
votes
4 answers

How to output a list of changed files from rsync?

I am using rsync in a bash script to keep files in sync between a few servers and a NAS. One issue I have run into is trying to generate a list of the files that have changed from the during the rsync. The idea is that when I run rsync, I can output…
Jason M.
  • 575
43
votes
6 answers

What command prints a string as "big ascii text art" in bash?

I'm looking for a program that turns an ASCII string into something like the "ascii art" below: .-"^`\ /`^"-. .' ___\ /___ `. / /.---. .---.\ \ | // '-. ___________________________ .-' \\ | | ;| \/--------------------------// |; | \ || |\_) Red Hat…
raoulsson
  • 4,943
43
votes
3 answers

Passing default answers to apt-get package install questions?

I'm trying to write a configuration script for new servers, and one of the first steps is to install a series of required packages, such as MySQL, phpMyAdmin, etc. using apt-get install However, when dpkg tries to configure them it asks you for a…
Tarka
  • 535
43
votes
11 answers

How do I read multiple lines from STDIN into a variable?

I've been googling this question to no avail. I'm automating a build process here at work, and all I'm trying to do is get version numbers and a tiny description of the build which may be multi-line. The system this runs on is OSX 10.6.8. I've seen…
Robert K
  • 612
39
votes
3 answers

For Loop counting from 1 to n in a windows bat script

I need to run a windows command n times within a bat script file. I know how to do this in various programming languages but cannot manage to get it right on the windows command line :-( I would expect something like either for(int i = 0; i < 100;…
raoulsson
  • 4,943
39
votes
9 answers

Multi-select menu in bash script

I'm a bash newbie but I would like to create a script in which I'd like to allow the user to select multiple options from a list of options. Essentially what I would like is something similar to the example below: #!/bin/bash OPTIONS="Hello Quit"…
user38939
  • 515
  • 1
  • 4
  • 7
38
votes
4 answers

What is needed for a linux service to be supported by chkconfig?

I am trying to add to the auto start at boottime a linux service through the chkconfig -add <servicename> and I get a message saying service <servicename> does not support chkconfig I am using Red Hat Enterprise 4. The script I am trying to add to…
Geo
  • 3,101
36
votes
8 answers

Is there any reason to use bash over zsh?

I'm curious about why one would want to run bash instead of zsh. I mean zsh is fully backwards-compatible with bash. Don't get me wrong: I don't dislike bash or anything. I just genuinely want to know if there are any advantages to using it over…
Jason Baker
  • 1,229
36
votes
5 answers

Where is a good permanent place to install custom Bash scripts?

I'm about to install Leiningen which is a useful Bash script for the Clojure programming language. The problem is, I'm not sure where it is appropriate to put a executable script in the Linux system so that it's permanently and stable-ly available.…
Kzqai
  • 1,328
32
votes
4 answers

How to configure postfix to pipe all incoming email to a script?

Using postfix, I'd like all incoming mail, to any address (including those that don't map to local users) to be piped to a script. I've tried configuring mailbox_command in /etc/postfix/main.cf : mailbox_command = /path/to/myscript.py This works…
user67641
  • 1,342
31
votes
14 answers

How do I find out what version of Linux is running?

Sometimes your scripts need to behave differently on different Linux's. How can I determine which version of Linux a script is running on?
jldugger
  • 14,640
31
votes
8 answers

How to use a config file (ini, conf,...) with a PowerShell Script?

Is it possible to use a configuration file with a PowerShell script? For example, the configuration file: #links link1=http://www.google.com link2=http://www.apple.com link3=http://www.microsoft.com And then call this information in the PS1 script:…
Xavier C
  • 783
30
votes
5 answers

How can a Linux Administrator improve their shell scripting and automation skills?

In my organization, I work with a group of NOC staff, budding junior engineers and a handful of senior engineers; all with a focus on Linux. One interesting step in the way the company grows talent is that there's a path from the NOC to the senior…
30
votes
11 answers

Sort a list of domain names (FQDNs) starting from tld and working left

I am looking to sort a list of domain names (a web filter whitelist) starting from the TLD and working upwards. I am looking any *nix or windows tools that can do this easily, though a script would be fine too. So if the is the list you are given…
Zoredache
  • 134,355