Browsing articles tagged with "scripting - Admins Goodies"
Apr 14, 2013
tom

Recursively delete empty folders with verbose output

This should be fairly simple, but I am not sure what i’m missing. I’d like to recursively delete empty directories, and get an output for what’s being deleted, this command works for sure, but I just can’t print the actions of -excec verbosely. while [ -n "$(find . -depth -type d -empty -exec rm -v -rf {} +)" ]; do :; done by recursively I mean, I want to keep deleting empty folders, until there’s [...]

Continue Reading »
Jan 9, 2013
tom

Ubuntu unattended upgrades to run at a certain time

I’m trying to work out the best way to run unattended upgrades every Thursday at 3am but can only see a way to run this weekly but not a given time. I thought of one way would be to have a script that is called by cron on Thursday at 3am The below script would work just for security updates #!/bin/sh sh -c ‘grep precise-security /etc/apt/sources.list > /etc/apt/secsrc.list’ sh -c ‘apt-get -o Dir::Etc::sourcelist=”secsrc.list” \ -o [...]

Continue Reading »
Jan 8, 2013
tom

Running a script containing find with a regexp fails in cron but works in a shell

I have the following script in my /etc/cron.d: 19 15 * * * root /opt/scripts/clean-nexus-release-repo.sh The clean-nexus-release-repo.sh script looks like this: #!/bin/bash find /opt/sonatype-work/nexus/storage/releases/se/company* -regextype posix-extended -depth -regex ‘.*/r?[0-9]{5,7}[a-Z0-9_.-]*\.[0-9]{1,3}’ -mtime +60 -type d -print -exec rm -r {} \; find /opt/sonatype-work/nexus/storage/releases/nu/company -regextype posix-extended -depth -regex ‘.*/r?[0-9]{5,7}[a-Z0-9_.-]*\.[0-9]{1,3}’ -mtime +60 -type d -print -exec rm -r {} \; When I run the clean-nexus-release-repo.sh script from my shell everything works fine. When it is run through cron I [...]

Continue Reading »
Dec 23, 2012
tom

is it possible to provide variable arguments to xinetd service?

I have created a bash script to listen on specific port (using xinetd), so whenever there is someone connecting to port, then it invokes the script and provides its output to user. But i need to provide dynamic arguments to server, for example when i telnet to server like telnet myserver 4535 then i should be able to pass an argument like my name “Frank” and it should say “Hello Frank” There is a parameter [...]

Continue Reading »
Nov 18, 2012
tom

run php script in the background

is there a way to launch a php script and let it run on the server until it finishes? I use this php5-cgi /var/www/script.php -q & connecting via putty. When I close it (the session) the script stops! Why does it run dependent on the session? Asked by Sandro Antonucci Try nohup and disown: nohup php5-cgi /var/www/script.php -q & disown Answered by Dennis Kaarsemaker Check more discussion of this question. Bookmark on Delicious Digg this [...]

Continue Reading »
Nov 15, 2012
tom

IIS script privileges with powershell

I’ve created a script for most of the functions I need when creating a Site for my IIS, however, there is still one thing missing. Namely, I can’t seem to find the commands for setting script privileges on a Site. I want all script rights but no execution rights if I’ve understood it correctly. So, how do you set those privileges through powershell? Edit: The answer I was looking for was: set-webconfigurationproperty -filter /system.webserver/handlers -name [...]

Continue Reading »
Nov 14, 2012
tom

How to stop basic Postfix after-queue script from BCC-ing sender?

I’m building a content filter for Postfix (2.9.3 package installed via apt on an Ubuntu 12.04 test VM) and I’m starting with a very basic Ruby (1.9.3) template and building up functionality. Strangely, when the script is enabled, messages sent are being forwarded on as normal, but also sent back to the sender which is not normal. Disabling the script disables this behavior. Any suggestions about what I have to change to stop that from [...]

Continue Reading »
Nov 9, 2012
tom

Delete Computer Object in AD with Powershell?

I am able to use the native add-computer cmdlet to join a computer to a domain, but it seems that this cmdlet fails if the systems already exists in AD, and you are trying to add it to a different domain. I would like to delete the existing object with powershell. Is this possible without loading the Active Directory Module? I am doing all this as part of system deployment, and don’t want to have [...]

Continue Reading »
Nov 2, 2012
tom

netsh doesn’t provide commands

According to Netsh Commands for Wired Local Area Network (LAN) in Windows Server 2008 and Windows Server 2008 R2, netsh should provide commands such as netsh add profile filename=”profile.xml” interface=”Local Area Connection” but that’s an unknown command for my netsh. Even if I enter netsh show /? it shows me only two options: ‘show alias’ and ‘show helper’. Maybe some library/modules or something is missing? I tested with admin permissions in PowerShell. Asked by Petr [...]

Continue Reading »
Oct 17, 2012
tom

How to make a Bash Script take user input for Changing a Password

The following command on OSX will change an Open Directory (Apple’s LDAP) password. The $ is the prompt: $ dscl -u diradmin -P ‘password’ /LDAPv3/127.0.0.1 passwd /Users/username newpassword I would love to turn this into an interactive shell script of some sort (let’s call it ‘odpasswd’) that first prompts the admin for the username whose account they want to change passwords for, then for the password, along these lines: $ odpasswd $ Username you’d like [...]

Continue Reading »
Pages:1234567...50»