scripting

How do I run a .vbs file from within Microsoft Script Editor?

Is it possible to open Microsoft Script Editor, then from within the editor open a .vbs (VBScript) file, then run/debug it? I know I can use the command-line cscript (filename) //X to launch the file, allowing me to select Microsoft Script Editor as the debugger, but I want to do everything from within Microsoft Script Editor. I am awa...

Real time scripting language + MS DLR?

For starters I should let you guys know what I'm trying to do. The project I'm working on has a requirement that requires a custom scripting system to be built. This will be used by non-programmers who are using the application and should be as close to natural language as possible. An example would be if the user needs to run a custo...

Dealing with quotes in Windows batch scripts

In a Windows batch file, when you do the following: set myvar="c:\my music & videos" the variable myvar is stored with the quotes included. Honestly I find that very stupid. The quotes are just to tell where the string begins and ends, not to be stored as part of the value itself. How can I prevent this from happening? Thanks. ...

Maven package .bat script: how to add a delay?

I have this .bat script which I use to maven package my application. Problem is, just after it ends execution, it closes the console window. The last 2 lines somehow are completely ignored. Does anyone know the trick to make this work? I just want to have a quick check if the build was successful. @echo off cls cd C:\svn\project mvn pa...

Bash - Passing arguments by reference

Hi all, I want to ask if it is possible to pass arguments to a script function by reference: i.e. to do something that would look like this in C: Void boo (int & myint) { myint= 5; } main (){ int t= 4; printf t; // t->4 boo (t); printf t; // t ->5 } So then in BASH I want to do somthing like: Function boo () { ...

Shell scripting to generate an EC2 image

I am getting started with Amazon EC2 and it looks like the best way to go is to generate scripts that take a base OS image and configure the OS/apache/php/mysql after boot-up. That way you can always change base images without having to redo everything. Sometimes when you do an apt-get install on a package, it asks you configuration ...

Separating data from a constantly appended file into a new file

I am using a macro to export a table in a Microsoft Access database to a csv file in order to import into a mysql database. I ended up using a batchfile that would place a marker in the text file before the exporting took place, and then place everything after the last marker into a new file. This works fine, except for the fact that acc...

Bulk modification of unique ids in SQL Server

[This is a bit of an unusual problem, I know...] What I need is a script that will change every unique id value to new one in our database. The problem is that we have configuration tables that can be exported between instances of our software which is id-sensitive (clobbering existing ids). Years ago, we set up a "wide-enough" id gap ...

How can I use a code ref as a callback in Perl?

I have the following code in my class : sub new { my $class = shift; my %args = @_; my $self = {}; bless( $self, $class ); if ( exists $args{callback} ) { $self->{callback} = $args{callback}; } if ( exists $args{dir} ) { $self->{dir} = $args{dir}; } return $self; } sub test { my ...

Batch Script to read each line of text file and return a value?

I want to write a batch script that should read a text file line by line and search for a keyword. If the keyword is found it should return value 0 else it should return 1. Like this it should keep on incrementing the value until the end of the file. The output should go to a file. The sample log is as follows, Website is available HT...

Windows Scripting: VBScript, DOS, JS, Python, ...

Say you were mainly a C-syntax like programmer and Linux systems administrator, and you were tasked with creating some simple automation tasks on Windows (monitoring of back-up files, process monitoring, ...). Which language would you prefer to write your scripts in? There's a large collection of VBS-scripts out there (using VB syntax), ...

is it possible to call a sql script from a stored procedure in another sql script?

I'd like to use . to call sql script from inside a stored proc like so... delimiter /// create procedure append_procedure() BEGIN \. test.sql; END; /// delimiter ; I'm getting a "failed to open 'test.sql;' " error when I run it this way. I've also tried ! but then I get a permission denied error. However, I can't eliminate the ;...

How can I make changes to only the first line of a file?

I would like to know which pattern can I use in sed to make changes in the first line of huge files (~2 GB). The preference for sed is only because I assume it must be faster than a Python or Perl script. The files have the following structure: field 1, field 2, ... field n data and, given the likelihood of having spaces in the ident...

What is the best technology to use for automating a task using .net libraries?

Imagine that you need to develop and schedule an application/script to do the following:- Reference one or more .net assemblies Query the API, get some objects for each object call another method in the API What would you use? In the past I have created small console applications that do the above, but it seems a bit clumsy and over...

Anyone know of any staticly-typed scripting languages?

I'm about to start an LFS-based linux distro just for a hobby project. I plan on doing some very non-standard tasks, and most of it will involve change almost all scripts in the distro. (mainly init scripts, but also I'll be writing a simple set of package manager scripts.) Since I'm gonna be going this far off the norm, and since I have...

Command-line dialog tool for Windows

I need a dialog tool similar to cdialog (or whiptail), but one that will work on Windows. I have MinGW and compiling something from source is no problem, but both cdialog and whiptail, the only ones that I know of, contain code that is UNIX-specific, and so they will not compile on Windows. Are there any alternatives that I can use? I...

What is the difference between spawn and exec?

I'm learning to write a TCL (expect) scripts and I notice that some examples show to use spawn, while others show the command exec. I tried googling, but can't find what is the difference? Suppose I call 'exec' in a middle of a long expect script, what can I expect to happen? ...

Repeat a unix command every x seconds forever.

There's a builtin unix command repeat whose first argument is the number of times to repeat a command, where the command (with any arguments) is specified by the remaining arguments to repeat. For example, % repeat 100 echo "I will not automate this punishment." will echo the given string 100 times and then stop. I'd like a similar ...

Calling a script from a setuid root C program - script does not run as root.

I need to run a bash script as root (passwordless sudo or su not viable) and since you cannot setuid a script in Linux, I thought about calling it from an executable and making it setuid: $ cat wrapper.c int main(void) { system("/bin/bash ./should_run_as_root.sh"); } $ gcc -o wrapper wrapper.c $ sudo chown root wrapper $ sudo ch...

How to rename/move all files with a certain extension?

I'm learning tcl (expect) and now I came to an interesting issue. I need a command to move/rename a bunch of files with extension .status. I tried these: spawn /bin/mv *.status some_dir exec /bin/mv *.status some_dir Of course, that did not work. I googled a bit and found something about glob, but it doesn't seem to work the way I wan...