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

learn more… | top users | synonyms (2)

11
votes
3answers
12k views

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: ...
19
votes
5answers
11k views

Scripted install of MySQL on Ubuntu

I need to write a script that will build my server from a fresh Ubuntu server install. Among things like Apache and PHP it needs to install MySQL. The only problem here is that when I install MySQL ...
25
votes
14answers
11k views

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?
8
votes
4answers
6k views

Fast extraction of a time range from syslog logfile?

I've got a logfile in the standard syslog format. It looks like this, except with hundreds of lines per second: Jan 11 07:48:46 blahblahblah... Jan 11 07:49:00 blahblahblah... Jan 11 07:50:13 ...
82
votes
8answers
139k views

Run a .bat file in a scheduled task without a window

I have a scheduled task that starts a batch script that runs robocopy every hour. Every time it runs a window pops up on the desktop with robocopy's output, which I don't really want to see. I ...
14
votes
2answers
81k views

Using ICACLS to set permissions on user directories

I'm trying to reset permissions on user directories and having a bit of trouble with the last step of my script. My script basically takes ownership of the entire user directory, resets the ...
4
votes
9answers
11k views

How to restrict the users' shell allowing to execute shell programs

Is it possible to prevent any user to not use commands like ls, rm and other system commands which could harm the system. But the users should be able to execute shell programs.
48
votes
6answers
12k views

Why use Chef/Puppet over shell scripts?

New to Puppet and Chef tools. Seems like the job that they are doing can be done with shell scripting. Maybe it was done in shell scripts until these came along. I would agree they are more readable. ...
4
votes
2answers
252 views

Repartitioning two disks without a loss of data

I am interning at a software company and I have hit somewhat of a brick wall. Here is the deal: The Problem: We have some boxes around here that were incorrectly partitioned for 2 x 500 GB drives. ...
6
votes
6answers
17k views

Delete temporary files from batch script in xp

I'm looking for a good batch script that would quickly find & clean all the known safe temporary folders/files from Windows (as many variants as possible) machines (e.g. the windows temp folder, ...
216
votes
11answers
252k views

How to determine if a bash variable is empty?

What is the best way to determine if a variable in bash contains ""? I have heard it recommended that I do if [ "x$variable" = "x" ] Is that the correct way? (there must be something more ...
116
votes
3answers
41k views

What is the difference between double and single square brackets in bash?

I just wondered what exactly the difference between [[ $STRING != foo ]] and [ $STRING != foo ] is, apart from that the latter is posix-compliant, found in sh and the former is an extension ...
17
votes
7answers
17k views

How do I run a local bash script on remote machines via ssh?

I am looking for a way to push configuration from one central machine to several remote machines without the need to install anything on the remote machines. The aim is to do something like you ...
5
votes
2answers
2k views

Tips for optimizing RHEL/CentOS kickstart workflow

I'm working in an environment that consists of CentOS systems located in multiple data centers and office locations. I've been using a reasonable kickstart with a solid post-install script, but want ...
16
votes
4answers
14k views

How to automatically run a script when the contents of a directory changes in Linux?

I want to automatically run a script whenever new files are copied into a particular directory. In other words, is there a way in Linux to "watch" a directory for changes and then run something in ...
3
votes
6answers
2k views

Windows XP autostart process as administrator

I am looking for a way with which i can autostart a certain program on logon of a user with user-rights with administrator-rights. I already tried using task scheduler but it didn't work out because ...
2
votes
2answers
4k views

Linux (Ubuntu) run script upon USB mount

I have a Ubuntu server with a external USB hard drive. I basically just want to run a script whenever the hard drive is plugged in. What would be the optimal way to achieve this ?
14
votes
6answers
42k views

Run a shell script as a different user

What's a good way of running a shell script as a different user. I'm using Debian etch, and I know which user I want to impersonate. If I was doing it manually, I would do: su postgres ...
3
votes
7answers
26k views

Batch file to MASS ping group of computers on network by name, check reply, and resolve hostname

So, I have a list of 5000 computers on my Windows Active Directory network that may or may not still exist (I know, don't ask...I need to know for a project, and of course little help from the network ...
4
votes
4answers
847 views

Linux: How to change the extension of a bunch of files?

I have a directory full of files ending with .xxx. (Apple.xxx, Orange.xxx, Bannana.xxx) I want to change their extensions to .yyy. (Apple.yyy, Orange.yyy, Bannana.yyy) What's the quickest way to ...
8
votes
6answers
3k views

What does passing the -xe parameters to /bin/bash do

Exactly what the title says. I'm not having much luck finding the proper documentation to see what -xe does in the following use case: #!/bin/bash -xe what do those parameters do and where it is ...
4
votes
2answers
2k views

Can I “register” python scripts to execute on Windows?

I have Python 2.5 installed on Windows XP and a collection of scripts available in a certain directory. According to this article by Amanda Birmingham I can setup up a path for the Python executable ...
2
votes
3answers
17k views

How to switch proxy settings via script?

There are a number of users in our organization that use their laptops on multiple networks. Each network has its own proxy setting requirements for accessing the Internet and currently, the users ...
0
votes
1answer
227 views

Linux (CentOS) - Is there any (feasible) way to add a file write “hook”?

I have a mod_security log parsing script to load data into a mysql database which is then accessed by our Project Management System to display recent flaggings by the rulesets for our developers. The ...
0
votes
4answers
906 views

FTP from batch file

I'm trying to use a batch file to download a package off my FTP server. echo username >ftp.txt echo >>ftp.txt echo cd directory >>ftp.txt echo get filename >>ftp.txt ftp ...
6
votes
4answers
7k views

Is it possible to run a command on windows server from Linux?

I want to restore a sqlserver db backup on remote windows server from linux. I tired "net rpc" but there is nothing for execute a command or script on remote server.
2
votes
2answers
2k views

compare the contents of two folders that are replicating by dfs

I have a large folder that I am replicating by dfs and I want to check that all files have been replicated correctly. Currently I am running the following script at both ends. cd e:\data\shared\ dir ...
1
vote
1answer
2k views

replacing a line or date in a text file using powershell

I am trying insert today's date on a text file at line 59. How do i do this? Line 59 has like 30 spaces and then reads like this. After the PowerShell script runs it will change the date so it has to ...
1
vote
5answers
504 views

FTP script needs blank line

I am trying to determine the reason for some FTP servers requiring a blank line in the script as follows: open server.com username ftp_commands bye Refer to blank line required after username ...
1
vote
0answers
330 views

How do i create a bat file to create user directory with proper rights and a script to reset it if something goes wrong

I need to create user and directories for the user and share it. The rights are set on NTFS structure only. The user must do all except change rights and take ownership this is not allowed and this ...
1
vote
6answers
1k views

Create auto restart Script in Linux

i have a small logging tool on my linux box that need to be restart once every 20-30 minutes because the log node shuts down the session every once in a while. how wold you go about creating a script ...
0
votes
2answers
1k views

Add Group Policy by Script

I'm trying to make it easy to add a LogOff script to Group Policy and am having difficulty finding any information on adding Group Policy via script. I already have the script I want to run at ...
-1
votes
2answers
72 views

Trying to bind a port on a completely different IP yet says it is in use

My host has given me a range of usable IP's for example (10.1.2.100 - 10.1.2.105). These did not come pre-bound to the OS, so I manually had to bind them. The only problem I am having is that when I ...
-2
votes
1answer
225 views

shell script doesn't run correctly in cron [closed]

I want to call a shell script I wrote from a cron. The shell script uses the program Linkchecker. If I run the shell script from the terminal it works just fine. However, when cron runs I get the ...
33
votes
8answers
5k views

How can I run arbitrarily complex command using sudo over ssh?

I have a system that I can only log in to under my username (myuser), but I need to run commands as other user (scriptuser). So far, I have come up with the following to run the commands I need: ssh ...
29
votes
8answers
25k views

How to make bash scripts print out every command before it executes?

For example, I have a simple bash file #!/bin/bash cd ~/hello ls How can I make it display every command before executing it? Just the opposite effect of "@echo off" in windows batch scripting.
26
votes
13answers
1k views

How to encourage Windows administrators to pick up scripting?

When I worked as an administrator in my first job, I was frustrated that our administration processes with Windows servers were a series of point-and-clicks; we could never match the level of ...
11
votes
2answers
7k views

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 ...
4
votes
7answers
24k views

Execute program on remote computer using PowerShell

How can I execute a program on a remote machine using powershell?
2
votes
2answers
4k views

Script to reset home directory permissons on a windows share

Has anyone used a script to reset the permissions on a directory of Home Directories? I'm thinking some combination of FOR loops and CACLS to add an inheritable Modify permission to a folder using ...
10
votes
3answers
1k views

Deploying Printers via GPO/GPP - is there a programmatic option?

For reasons beyond my control, I've been tasked with setting up GPO/GPPs to deploy our 100+ printers to our 1000+ clients. The good news is that we have over a dozen sites, and for the most part, I'm ...
10
votes
5answers
9k views

Using mysqldump in cron job without root password

If I login with the root password on my box I can simply type mysqldump --all-databases and I will get th expected "Dump". I setup a job in cron.daily to run and dump this to a backup drive. The ...
8
votes
9answers
7k views

Batch Query Dell Service Tags

Anyone know of a way to get a bunch of information for a list of service tags, does Dell have a section on their site for this? I would also be open to any Perl / Python libraries or *nix shell ...
7
votes
1answer
190 views

How do I remotely issue a CLI command to thousands of Windows domain computers at once?

I need to issue a CLI command (cmd.exe or PowerShell) to all of the thousands of computers on my domain. For obvious reasons, this is not going to involve doing the task manually, or physically ...
4
votes
5answers
1k views

Bash: Quotes getting stripped when a command is passed as argument to a function

I am trying to implement a dry run kind of mechanism for my script and facing the issue of quotes getting stripped off when a command is passed as an argument to a function and resulting in unexpected ...
4
votes
2answers
2k views

How To Shutdown Ubuntu Automatically X Minutes After Starting Up?

How would one automatically shutdown an ubuntu OS 30 minutes after it was turned on? Or 15 minutes after it was turned on? Etc? I tried creating an init.d script like so: shutdown -h +5 But my box ...
3
votes
1answer
907 views

Amazon EC2 notifying the instance when the autoscale service terminates it

I am in need of knowing when an instance is supposed to be shutdown by the autoscale, as I want the instances to register themselves and deregister themselves from a given service. I know that the ...
3
votes
2answers
774 views

SQL Server Management Studio not scripting all objects

i've been attempting to script a database using SQL Server 2005 Management Studio. i cannot get it to script some objects. It scripts others, but skips some. i can provide detailed screen shots the ...
2
votes
1answer
910 views

Script to do Windows Update on windows server 2003

Is there any batch script or command line command that can do Windows Update automatically on multiple remote servers (maybe via psexec)? Not prefer using a VB script, but if there's one available, ...
2
votes
4answers
3k views

What's the best way to send bulk email?

I have been using the sendmail function in PHP with Exim 4 so far when I had to send my mailing lists, I would like to know if there is a clean solution for that. I'm quite sure that Facebook isn't ...