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)

7
votes
1answer
7k views

How can you debug a Data Input Method script in Cacti?

(See bottom for updates...) I've written a data input method script for Cacti (in Ruby, to collects stats from beanstalkd) and it works from the command line (returning a single simple integer, as ...
6
votes
9answers
1k views

Successfully, permanently ban a user from a website? [closed]

I have a social networking website and I want to ban a user from the website. I've added his IP address to the ban list in the .htacess file and to the php level for banning that user, but he keeps ...
6
votes
8answers
12k views

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.
6
votes
4answers
274 views

How to determine how many shells deep I might be?

I'm wondering whether I've called the shell recursively, is there an easy way to find out? Is any solution specific to the shell? I'm using bash.
6
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 ...
6
votes
4answers
11k views

How can I prevent a scheduled task from running if the same task is already running?

I have written a php script to check if there are any new files in a folder and, if any new files exist, upload them to a server. These files can be quite large. I want to run this script ...
6
votes
5answers
18k views

Can the Windows telnet client be scripted?

Is it possible to use the Windows Telnet client to run a series of commands in a script? If not are there any alternatives that can be?
6
votes
3answers
3k views

echo based on grep result

I need a one liner which displays 'yes' or 'no' whether grep finds any results. I have played with grep -c, but without success.
6
votes
6answers
16k 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, ...
6
votes
4answers
7k views

Is there a way to prevent Thumbs.db from being created, on the SERVER side?

I have some scripts running on files located on a shared drive on a Win2003 Server. I need to look at the images on any number of PC's in our network.. so every time I browse these folders, the ...
6
votes
5answers
2k views

Do Windows batch files have a %* construction?

In a batch file, do I have to do (e.g.) the following? @echo off call other.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
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.
6
votes
3answers
445 views

Run shell script on a command

I want to run a shell script when date -s <string> command is used. For example i want to log the command to the file /tmp/user.log by executing the following command in the shell script ...
6
votes
2answers
2k views

Where do you share or find useful powershell, bash, batch, vbs, scripts?

I just wrote a quick little powershell script to make my life easier for a task that I was facing. I thought it would be nice to put it on the Internet, where someone else may also find it useful. The ...
6
votes
6answers
4k views

how to write a script that only acts on new log entries

I feel like this should be a simple thing but I am having a hard time figuring it out. I am trying to write a script that will monitor one of the apache log files and take some specific action. But ...
6
votes
4answers
2k views

Vim - Trigger action\script on save\write?

This might be better for super user, but I figure as a tool of the trade it might be a better topic for here. I find often when editing in vim that I exit out, run some script that I am testing, and ...
6
votes
2answers
409 views

Bash script parameters

I need to write a bash script, and would like it to parse unordered parameters of the format: scriptname --param1 <string> --param2 <string> --param3 <date> Is there a simple way ...
6
votes
1answer
7k views

AppCmd to create a virtual directory in default web site in IIS7

I try to create a virtual directory under the "Default Web Site" in IIS 7 using AppCmd. First I however like to see if one already exist. How can I use AppCmd to create a virtual directory under the ...
6
votes
7answers
2k views

Need a script/batch/program that runs a command that won't be killed when the parent is killed

The scenario I use Zabbix to monitor my servers and recently I wanted to add some more metrics for the Windows ones. For security reasons, I used Zabbix's User Parameter feature, but it limits the ...
5
votes
5answers
416 views

Bash: mv directory one at a time

I am trying to move all subdirectories of a folder to another share on the same server. If I do a mv *, I will run out of space since the folders are not removed until all folders get transferred. ...
5
votes
3answers
367 views

Bash variable assignment using another variable as part

I have the following excerpt from a bash script used to backup a database #!/bin/bash DB=database_name DBUSER=username FILENAME=$DB_$(date +%s).sql I am trying to reuse the value of DB within the ...
5
votes
7answers
5k views

Get Latest Tag From Subversion

Is there a way to determine the newest tag in subversion? For an application I've deployed the client needs to have another server that they can access in case the live server goes down. There is ...
5
votes
4answers
7k views

How to Automatically and Temporarily block an IP address making too many hits on the Server in a short timespan?

One of my LAMP servers was recently brought down by some kind of script bot looking for exploits. From the looks of it, it was making so many requests a second, that it overloaded the RAM on the ...
5
votes
4answers
6k views

Perl or Python, better suited for Unix system automation?

I have been using bash for most of my system administration tasks. I also know a bit of perl. Should I learn Python or Perl is better for system automation. So far from my experience learning perl ...
5
votes
5answers
4k views

BSD - Remove non-ascii characters from all files in a directory recursively

I'm trying to migrate a bunch (300GB+) of files from a FAT32 drive to my freeNas ZFS filesystem but every command I throw at it (tar,pax,mv,cp) throws an 'invalid argument' when it encounters a ...
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 ...
5
votes
4answers
5k views

Find GUID of MSI Package

How can I find the GUID of an MSI package? I would like to script the removal of a program on a large number of desktops by using: msiexec.exe /x ProductCode Any reason why this would not work ...
5
votes
6answers
5k views

Useful WMI admin scripts

In a comment to my response to this question , cop1152 said he loved WMI scripts. Well, so do I! What are your favourite, best, most useful scripts you'd like to share with the community? thanks.
5
votes
2answers
2k views

Windows Group Policy Startup script is not executed at startup

I have written a .cmd file which calls ten different .exe files. I am able to run this .cmd file locally, on my server, and it works fine. When I use [gpedit.msc] (Group Policy Editor) for "Computer ...
5
votes
7answers
10k views

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. ...
5
votes
3answers
338 views

Can I create and manipulate unix “screens” in a script?

I have a work environment on my Ubuntu laptop in which I want to use three different screens. Eg. in terminal, I usually write screen -S mywork run_server_1 then, ctrl-a c to create a second ...
5
votes
4answers
511 views

Is there a chroot build script somewhere?

I am about to develop a little script to gather information for a chroot-jail. In my case this looks (at the first glance) pretty simple: The application has a clean rpm-install and did install ...
5
votes
1answer
4k views

Cacti graph not showing

I have created php script for cacti which outputs data in format like: <variable>:<value> Output of my script: temperature:20 humidity:15 Then I created data input method where input ...
5
votes
4answers
5k views

How to script printer creation on a Windows Server 2008 R2 clustered print server?

As per subject. I've found some ways of scripting printer creation on Windows print servers using WMI, but it looks like WMI doesn't support clustered print servers (or clustered servers at all). ...
5
votes
3answers
3k views

Ubuntu Upstart script hangs on start and stop

I have an upstart script that will start a custom jetty server. When I do sudo start [myservice] nothing happens. Subsequently, sudo status [myservice] show it as: [myservice] start/killed, process ...
4
votes
9answers
10k 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.
4
votes
4answers
840 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 ...
4
votes
7answers
20k views

Move stored procedures from one database to another in SQL Server

I'm using SQL Server 2008, and I would like to copy stored procedures from one database to another. How?
4
votes
2answers
527 views

Where is the script that creates home folders in linux?

I want to added public_html and private_html folders for users of my web server (Fedora 8 or 10 or something). Where is the script that will create those folders for them when they log on? Is there ...
4
votes
5answers
233 views

What is wrong with following bash script?

I wrote following line in my script , but it not assigning any value to variable a a= grep -n mark /etc/samba/smb.conf |cut -d: f1 I aspect line number where mark string present in smb.conf in ...
4
votes
12answers
8k views

Cisco Guy looking for best language to automate tasks and pull info from routers & switches [closed]

I am a cisco engineer and am wanting to learn ways to automate tasks for router and switches and pull info, etc... I am unix/linux challenged. So I deal with windows. Perl or Ruby keep coming up ...
4
votes
5answers
1k views

Is it worth while to learn Awk?

I am decent with bash scripting and I am catching on to regex, and a little sed usage. Is learning awk still worth while with all the alternatives out there. Opinions?
4
votes
4answers
218 views

Disabling ssh as root on Linux boxes and the challenges of writing scripts

It's a common suggestion from security-minded people to disable ssh as root on Linux boxes. My question is this: Let's say you normally write lots of scripts which ssh to a large number of Linux ...
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 ...
4
votes
5answers
2k views

Bash snippet for killing a process until it's dead?

I'm trying to write a robust bash script, and in it I create a background process. At the end of the script, I want to kill it. I have it's PID. I was thinking of somthing like this while [[ ps ef ...
4
votes
5answers
754 views

Bash: Execute piped lines from stdin

I haven't found a solution to this after some searching. I think the search terms are just too general. I'd like to know how to execute a number of lines (at the bash prompt) which are generated by ...
4
votes
7answers
16k views

script to automatically test if a web site is available

I'm a lone web developer with my own Centos VPS hosting a few small web sites for my clients. Today I discovered my httpd service had stopped (for no apparent reason - but that's another thread). I ...
4
votes
7answers
23k views

Execute program on remote computer using PowerShell

How can I execute a program on a remote machine using powershell?
4
votes
1answer
350 views

Run specific script after every Windows Update

Is there a way to run a specific script each time Windows update completes (i.e., after reboot or after an update that doesn't require a reboot)? My application is suffering from MSCOMCTL.OCX ...
4
votes
6answers
438 views

Prevent sudo, apt-get, etc. from swallowing pasted input to STDIN?

I often write up wiki instructions to install various server packages on Ubuntu (11.10 Oneiric at the moment). They always involve things like: sudo apt-get install -y postfix sudo cp ...