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)

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
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
6k 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
433 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
3answers
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
2answers
1k 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
3k 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
2answers
402 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

How to start tomcat in remote debug mode under Ubuntu 10?

I'm getting crazy to set up Tomcat in remote debug mode under ubuntu 10. Basically I added this to /etc/init.d/tomcat6 (at the beginning): JAVA_OPTS="-Djava.awt.headless=true -Xmx256M -Xdebug ...
6
votes
6answers
3k views

Setting the Timezone with an automated script

I'm writing scripts to automate setting up new slicehost installations. In a perfect world, after I started the script, it would just run, with no attention from me. I have succeeded, with one ...
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 ...
5
votes
5answers
390 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
6answers
2k 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 ...
5
votes
3answers
357 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
8answers
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
3answers
2k 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.
5
votes
4answers
5k 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
3answers
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 ...
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
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
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
3answers
322 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
7answers
8k 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
4answers
417 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
7answers
1k 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
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
4answers
19k views

How can i fully log all bash scripts actions?

I want to capture ALL the logs data, both with error messages, from my script output, and redirect them all to log file. I have script like below: #!/bin/bash ( echo " `date` : part 1 - start " ssh ...
4
votes
9answers
9k 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
820 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
19k 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
521 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
231 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
7k 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
209 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
1k 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
574 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
21k views

Execute program on remote computer using PowerShell

How can I execute a program on a remote machine using powershell?
4
votes
1answer
262 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
14k 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
6answers
12k views

How to get the IP Address for your Local Area Connection on Windows Server?

I want to create a batch or vbs file that will put together a url and executed. Part of that url needs to be the actual ip address of the machine. How I am able to get that IP address in a variable ...
4
votes
2answers
3k views

Run a script after I unlock my Windows session?

How do I run a script each time I unlock my Windows 7 session? So, if I lock my session and then log in again, I want the script to run. Do login scripts configured in the Group Policy do this or ...
4
votes
6answers
2k views

How to remove a tagged block of text in a file?

How can I remove all instances of tagged blocks of text in a file with sed, grep, or another program? If I have a file which contains: random text // START TEXT internal text // ...
4
votes
2answers
366 views

What is the best way to keep track of changes people are making to your servers?

HI Folks, I work at a company with a handful of windows servers in production running our software as a service offering. Part way through making a bunch of changes such as creating new Databases, ...
4
votes
3answers
4k views

Importing a large SQL script into SQL Server?

I'm trying to move a database from our production server to our test server. I've used Microsoft's Database Publishing Wizard to create a script containing the schema and data for the production ...
4
votes
5answers
822 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 ...