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.

1826 questions
42
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
  • 525
  • 1
  • 4
  • 9
42
votes
7 answers

Bash Scripting: Require script to be run as root (or with sudo)

I'm trying to write a bash script (in Ubuntu) that will backup a directory using tar. How can I do a check in the script so that it can only be run as root (or with sudo)? For instance, if a user runs the script, it should say that this script must…
Cory Plastek
  • 979
  • 2
  • 8
  • 14
40
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: .-"^`\ /`^"-. .' ___\ /___ `. / /.---. …
raoulsson
  • 4,763
  • 10
  • 34
  • 29
39
votes
10 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
  • 572
  • 1
  • 5
  • 12
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 and I get a message saying service does not support chkconfig I am using Red Hat Enterprise 4. The script I am trying to…
Geo
  • 3,071
  • 11
  • 42
  • 52
37
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 …
user38939
  • 495
  • 1
  • 4
  • 7
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
  • 6
  • 20
  • 26
36
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,763
  • 10
  • 34
  • 29
35
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…
Kzqai
  • 1,278
  • 4
  • 18
  • 32
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,342
  • 20
  • 77
  • 129
31
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,292
  • 2
  • 14
  • 18
29
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…
ewwhite
  • 197,159
  • 92
  • 443
  • 809
29
votes
10 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…
Zoredache
  • 130,897
  • 41
  • 276
  • 420
28
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…
Xavier C
  • 733
  • 2
  • 9
  • 12
27
votes
3 answers

scp files and delete files on remote directory

I am a unix noob, so please be patient :-) I have a script that scps a bunch of files to another server. Suppose they are z1.foo, z2.foo etc. What I want to do is to scp files and delete files older than 5 days in the destination server. How do I…
Kapsh
  • 519
  • 2
  • 6
  • 7