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)

3
votes
5answers
763 views

linux logfile does not open correctly in windows notepad

I have a small piece of code on my red hat linux box like echo $ddate";"$time";"$cpu >> /home/logfile The output is in vi 2010-04-10 12:23:32;01 2010-04-10 12:23:32;01 2010-04-10 12:23:32;01 but ...
3
votes
4answers
3k views

Testing for a script that is waiting on stdin

Is there a way to determine if a script is waiting on stdin and cause the command to exit if detected? Here's an example, the command I'm executing takes a long time to run, but it will also prompt ...
3
votes
3answers
697 views

Year Month day from file name in shell script

I hava file names like below adn_DF9D_20140515_0001.log adn_DF9D_20140515_0002.log adn_DF9D_20140515_0003.log adn_DF9D_20140515_0004.log adn_DF9D_20140515_0005.log adn_DF9D_20140515_0006.log ...
3
votes
1answer
572 views

How can I automatically delete /tmp folder on shared drive?

We have a /tmp folder that people use for temporary stuff. It can be anything and any file. We want to make it so that this automatically deletes (or preferably MOVES to another folder on the same ...
3
votes
2answers
86 views

what type of scripting is this and is it suggested for my environment? [closed]

First of all, I hope I am not duplicating another post. If so I will delete immediatly. I have gone through many of the questions/answers on this website trying to find what scripting language I ...
3
votes
1answer
165 views

echo $? doesn't work when executed remotely

When I execute a command as below it gives me an output as expected but when I run the same command on remote server it always gives me echo $? as 0. locally # <some command> # echo $? ...
3
votes
3answers
147 views

Direction for Scripting

I'm administering a network and they use a few scripts here. Mostly batch scripts or vbscript. It's a Windows environment, mostly Server 2008 with a few 2003 servers. My question is Should I learn ...
3
votes
2answers
9k views

Delete registry key via CMD script?

I'm want to edit an already production .cmd script file, to have the script delete a certain registry key in the Windows registry. Firstly, is this even possible, and secondly (if that's not ...
3
votes
3answers
8k views

How to use a config file (ini, conf,…) with a Powershell Script ? Is it possible?

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

How to 'echo “” > x' on multiple files

What is the best way how to empty a bunch of files in bash? As far I've been doing this echo "" > development.log echo "" > production.log I don't really want to delete those files, so rm is ...
3
votes
4answers
1k views

Change all network cards to auto/auto on many machines

Because of a change in networking equipment I might need to set a bunch of machines NICs back to auto negotiate. What's the best way to automate this? I'm thinking an Autoit compiled exe pushed out ...
3
votes
3answers
231 views

simple nagios script failing

What is wrong with the following if-then-else? I never can hit the else. if [ $result > $value ]; then echo HEALTH: OK. Result is $result Value is $value exit 0 else echo HEALTH: ...
3
votes
4answers
830 views

How can I search IIS logs of several servers at the same time?

I need to search the logs of all the servers in the array for a particular string. Specifically, I need to determine if a given user is using OWA, EWS, or something else with our CAS servers. Is ...
3
votes
1answer
862 views

How to Load commands into your powershell profile to run on starting powershell

I have found a way to load exchange 2010 powershell into powershell running on a windows xp workstation, however there are a few commands that need to run. I was wondering how I could load them into a ...
3
votes
2answers
3k views

Evaluating expressions in windows batch script

This one could turn out as the dumbest question ever, as I am probably missing out the obvious. Anyway, here it is: Can you evaluate expressions in a batch script. For example, I want to add two ...
3
votes
7answers
1k views

Automating Administration Tasks on Windows

What tools do you use and recommend for automating administration tasks for Windows-based computers? Examples of such tasks include: Installing/upgrading software Standarizing application settings ...
3
votes
2answers
144 views

Discrepancy in ssh-agent behavior

It seems like i'm having a bit of a discrepancy between the behavior of ssh-agent for two accounts I have configured. I wrote a simple monitoring script to check on the availability of some VMs we ...
3
votes
2answers
798 views

How can I check for a string match AND an empty file in the same if/then bash script statement?

I'm writing a simple bash script to do the following: 1) Check two files (foo1 and foo2). 2) If foo1 is different from foo2 and foo1 NOT blank, send an email. 3) If foo1 is the same as foo2... ...
3
votes
3answers
1k views

how to rename a remote file on linux with script

I would like to have a (bash) script to rename a file on multiple remote linux servers any idea how to do it? thanks.
3
votes
3answers
1k views

More efficient method to synchronize very large # of files

I have a large directory that needs to be synced from a local server to my web server and am looking for the most efficient method of doing this. This directory contains 113k files in 14k directories ...
3
votes
3answers
5k views

scp files and delete files on remote directory [closed]

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 overwrite the files at the ...
3
votes
3answers
4k views

bash script with permanent ssh connection

I use a bash script which runs /usr/bin/ssh -f -N -T -L8888:127.0.0.1:3306 serveradmin@34.324.234.23 However, when I run the bash script, it waits.. I see the connection coming up but the script ...
3
votes
4answers
3k views

Need a way to run a script on windows boot up prior to a user logging in

I need to run a custom script which runs when Windows boots up.I know its possible to run it when a user logs in but I want to run it when the system reboots i.e. prior to a user logging in. The OS in ...
3
votes
3answers
565 views

Write shell script that can only be run by a sudo user in Ubuntu

I'm writing a shell script that is supposed to be run by users only in sudo user list, what's the appropriate way of doing this? what I'm thinking is in the shell script, try to create a dummy file ...
3
votes
1answer
961 views

How can I start multiple programs simultaneously?

I have 4 programs that I'd like to start by using only 1 script or shortcut. How can I achieve this? Is Powershell able to do that? I tried to do it using a .bat file but the script pauses until the ...
3
votes
1answer
168 views

“Threading” in Shell Scripts

I have a situation where I need to: Do some preamble setup in Script A Start Scripts B, C, D and E together, so they run concurrently When all four scripts have exited, do some cleanup in Script A ...
3
votes
7answers
2k views

Shell script to execute something when one of the daemon dies?

I just had to build two instances of daemon running on different ports. let's say they both serve critical missions for some applications. How can I do some automatic task (eg. shell script) ...
3
votes
3answers
663 views

Update a network driver through GPO/AD

Our organization has just deployed new computers with Windows 8.1. Roughly 50 of them. We've run into an issue with the driver on the new computers which is flooding the network with ipv6/multicast ...
3
votes
2answers
1k views

Shell script command output in if condition comparison fails to compare to same value string

I'm incorporating a script snippet which determines Android version via: adb shell getprop ro.build.version.release which returns: 4.1.2 or 4.0.4 The snippet currently looks like this: if [ "$(adb ...
3
votes
1answer
58 views

Getting WINS Server Statistics

I know WINS is ancient. No need to remind me. For what it's worth, this effort is going toward a project to retire it from the environment altogether. But before I can do that - I need to be able to ...
3
votes
8answers
753 views

How best to monitor and alert on the absence of an event in the logs?

With logs getting captured in syslog-ng, I'd like to be able to automatically monitor the logs and receive an alert if NO log events appear that match a certain criteria. For instance, for a ...
3
votes
1answer
470 views

Powershell and NMAP Information Sharing

I am working on a project where I would like to perform host documentation for a variety of items. Part of these items would be sourced from Powershell and the rest would be sourced from NMAP. For ...
3
votes
3answers
715 views

Email to run a bash script

I have a bash script to restart a service that runs every 3am to guarantee that the service isn't crashed when users require it. However, I need to provide a simpler way for my partner (that isn't ...
3
votes
1answer
186 views

Why start script with /usr/bin/env python

I just downloaded a python script and noticed that the "shebang" line at the top looks like: #!/usr/bin/env python instead of the familiar #!/usr/bin/python What's the reason for that?
3
votes
2answers
323 views

Linux script to identify security issues & generate report

I've previously used a great script on a Linux servers to report on all sorts of security issues. It generates a comprehensive list of potential security flaws on the machine including: out of ...
3
votes
4answers
2k views

How to execute a system-wide script upon any ssh login (with OpenSSH)?

Upon any ssh login/connection (anybody logging in through ssh), is there a way to have a script executed? Using OpenSSH server. The script should not be modifiable by any of the users, -- of course ...
3
votes
1answer
926 views

Including a bat file in a bat file

I have many bat files that share a common setup of variables. Instead of defining the same variables over and over again (and making errors in the process) I would like to include one bat file in all ...
3
votes
2answers
2k views

Can I use rsync to create a list of only changed files?

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 ...
3
votes
2answers
369 views

Redirect to 404 if filename passed as parameter does not exitsts

I have special parameter data=/path/to/filename.htm in uri. Its old and rusty site builded on SSI, and I can't modify it. Problem is when filename passed as arg_data not exists, page is broken. I ...
3
votes
1answer
475 views

Force Close a file not a process

I want to write a script that forces closed a specific file and then copies it from one server to another. To manually do this I would use Administrative Tools --> Computer Management --> Shared ...
3
votes
2answers
4k views

Install .msi from script, detect when install is done

I'm trying to make an install script. I want to install an .msi file, Python, and then install other things after Python is installed. I already see how to do a command-line install. However, msiexec ...
3
votes
1answer
491 views

IIS 6 Logging on a webfarm

Is there away in IIS 6 to programmaticly turn on/off logging in a web farm. we have 10 servers and I don't want to when needed log on to each and flip logging on, and then when we are done login and ...
3
votes
1answer
351 views

Change shortcut arguments via script

We have a program here that requires every user to have a shortcut on their desktop that points to an ini file. Each file is unique to the user. Recently, we've done a new install of the application ...
3
votes
1answer
2k views

How to retrieve the current Windows NLA network location from command-line?

We have a Windows Server 2008 R2 domain controller which always sets its NLA location to 'Network 3' after a reboot. Without fail, this defaults to Public, which screws with my Domain profile ...
3
votes
2answers
951 views

Backup script to FTP with timed subfolders

I want to make a backup script, that makes a .tar.gz of a folder I define, say fx /root/tekkit/world This .tar.gz file should then be uploaded to a FTP server, named by the time it was uploaded, ...
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 ...
3
votes
1answer
2k views

Verify who has Bitlocker key backed up via PowerShell?

We currently use Bitlocker on our laptops here at work. The helpdesk are responsible for backing the Bitlocker key up to AD when they build the system. We ran into an issue recently where a user had ...
3
votes
1answer
239 views

Rsync: General file/folder synchronization

I have a file server, which is in-charge of pulling a folder tree from multiple workstations on a daily basis. My current method for this is by using rsync, (which works pretty well provided directory ...
3
votes
2answers
2k views

Linux: ssh to host and use sudo to run a script, runs but part of script fails

I've searched high and low for an answer to this. I have keys setup so no password is needed for the ssh into remote host. I have sudo set up with that user so that I can run the needed commands as ...
3
votes
1answer
141 views

Test file for specific permissions

I have a script where I'd like to test a file for specific permissions, specifically 0644, if it is not that then chmod it. I know I could just chmod it and let it fall through in case it already was ...