scripting

In Python, how can I efficiently manage references between script files?

I have a fair number of Python scripts that contain reusable code that are used and referenced by other Python scripts. However, these scripts tend to be scattered across different directories and I find it to be somewhat tedious to have to include (most often multiple) calls to sys.path.append on my top-level scripts. I just want to pro...

What's a good tool to run SQL scripts against any database?

Currently I have a custom tool which generates vanilla-SQL (only using standard SQL), from our Data-models that sets up database schemas and initial data for our new databases, and do version patches, etc... This part is all fine and dandy right now. However running these SQL scripts against all the different databases (different vendor...

Macro/Scripting language for non-developers with a simple GUI-based editor

Hello, We wish to provide people to be able to add some logic to their accounts(say, given a few arguments, how to compute a particular result). So, essentially, this would be tantamount to writing simple business rules with support for conditionals and expressions. However, the challenge is to provide them a simple online editor where ...

URLEncode from a bash script

I am trying to write a bash script for testing that takes a parameter and sends it through curl to web site. I need to url encode the value to make sure that special characters are processed properly. What is the best way to do this? Here is my basic script so far: #!/bin/bash host=${1:?'bad host'} value=$2 shift shift curl -v -d "...

Update script for updating a table field in SQL Server from NULL to non-NULL

I have a field (say, foo) in a table in a SQL Server database that was originally defined as nullable, but new requirements indicate that this field must be non-null. What's the best way of updating this field to non-null via an update script without deleting the contents of the table? I tried generating a script from the Design view, ...

Reading a value from a file in a windows batch script

I'm trying to read a value from a file and use it in a subsequent command. I have a file called AppServer.pid which contains the process id of my app server (just the number, it's not a properties file or anything like that). The app server is hanging, so I want to take this value and pass it to the kill command. So my script will be s...

How to uninstall a windows service and delete its files without rebooting

My current project involves deploying an upgraded .exe file that runs as a Windows Service. In order to overwrite the existing .exe with the new version, I currently need to: (1) stop the service (2) uninstall the service (3) reboot the system (so Windows releases it's hold on the file) (4) deploy the new .exe (5) reinstall the ser...

Adding to %TIME% variable in windows cmd script

I realize that this could probably be done easier in any number of other scripting languages but started to do it quick in cmd and now Im curious. Looking to start a process at an offset to the time that another process started. Lets say 5 minutes to keep it simple. Is there a way to add to the %TIME% variable? For instance: start /...

Where do you keep your common sql task scripts?

In your workplace, where do you store your common, non-database specific scripts that you use in SQL Server? Do you keep them in .SQL scripts on the file server, do you store them in the Master database, or do you keep them in a database you defined specifically for these kinds of things? ...

Want to script Windows WMI (wmiprvse.exe) to release handle on file

I'm working with a VB Script file written by someone else that uses Windows Management Instrumentation (WMI) calls to check on the status of several Windows Services. This script runs every few minutes on set schedule. I need to upgrade/replace the .exe for those services. I stop the VB Script, stop the services, and uninstall the ser...

Programmatically log on to forum and then screenscrape

I'd like to login to the Forums part of community-server (e.g. http://tinyurl.com/cs-login) and then download a specific page and perform a regex (to see if there are any posts waiting for moderation). If there is, I'd like to send an email. I'd like to do this from a Linux server. Currently I know how to download a page (using e.g. w...

PSake extensions?

I recently discovered Powershell and through that PSake. If you are using it and you've extended it or created tasks for it, please share! ...

PHP Form not showing up in recipient's mailbox

Form does not go to recipient when submitted! I changed the file mail.tpl.txt to direct to my own email address as a test and I got the email just fine. Client has checked junk mail folder as well and he is just not getting information. Below is the form code, followed by the code from mail.tpl.txt and then the form's index.php code. ...

JRuby and Java objects

Please tell me if it's possible to do the following thing : create an instance of a specific class in Java pass it to JRuby to do something with it continue using the "modified" version in Java Please provide a small working example if it's not too much to ask . EDIT : turns out embedding was the simplest way to achieve this . More ...

What would be the right way to declare an array within a script that will be called by cron?

I've written a Korn Shell script that sets an array the following way: set -A fruits Apple Orange Banana Strawberry but when I'm trying to run it from within cron, it raises the following error: Your "cron" job on myhost /myScript.sh produced the following output: myScript.sh: -A: bad option(s) I've tried many crontab syntax vari...

PPP demand dial with modem bank in linux

I have a linux box with a bank of modems and need to create demand-dial (outbound) PPP connections to a very large set of remote machines. Since I have far more remotes than local modems, I'd like to launch one or more instances of pppd in demand mode, but not allocate a particular modem until a connection is requested. When the connec...

Remove quotes from named environement variables in Windows scripts

I want to store a URL prefix in an Windows environment variable. The ampersands in the query string makes this troublesome though. For example: I have a URL prefix of "http://example.com?foo=1&bar=", and want to create a full URL by providing a value for the bar param. I then want to launch that url using the "start" command. Addin...

How can I get a script's output to be copied to the clipboard (windows)?

Hello, I find myself running scripts and copy-pasting the output of these runs into emails or into some other documents. Is there a way such that I can make the copy-to-clipboard step a part of the script itself? Most of my scripts are either perl or bat files and I work on windows. Thanks, Rohit ...

How to delete files older than N weeks from a Microsoft FTP server

I run an OpenSuse server that uploads zipped source code backups to a Microsoft FTP server every night. I have written a Bash script that does this through a cron job. I want to delete backed up files that are older than a certain date. How could I do this? Thanks. ...

python as a "batch" script (i.e. run commands from python)

I'm working in a windows environment (my laptop!) and I need a couple of scripts that run other programs, pretty much like a windows batch file. how can I run a command from python such that the program when run, will replace the script? The program is interactive (for instance, unison) and keeps printing lines and asking for user input...