scripting

Best/conventional method of dealing with PATH on multiple UNIX environments

The main question here is: is there a standard method of writing UNIX shell scripts that will run on multiple UNIX platforms. For example, we have many hosts running different flavours of UNIX (Solaris, Linux) and at different versions all with slightly different file system layouts. Some hosts have whoami in /usr/local/gnu/bin/, and ...

Expression that either returns the output string from a program, or a specific string, if the program doesn't exist

I'm using mercurial as a SCM, and an output from the hg parents command in my makefile to store build number and version information in my program. However, mercurial is not always present on machines where I try to build the program. Thus, hg parent fails. I'd like to use a substitute string (hard-coded or output from other program) whe...

Writing to a file through a bash script

I want to write a bash script which takes 2 arguments, a and b. Based on the argument, it writes in section a or section b of a text file. Output file is a txt file something like this: common content.... section a: <everything should be written here when I specify option "a"> section b: <everything should be written here when I specif...

detect if something is modified in directory, and if so, backup - otherwise do nothing

I have a "Data" directory, that I rsync to a remote NAS periodically via a shell script. However, I'd like to make this more efficient. I'd like to detect if something has changed in "Data" before running rsync. This is so that I don't wake up the drives on the NAS unnecessarily. I was thinking of modifying the shell script to get the ...

How to install/remove Java quick start service from command line.

Would like to know how to install/remove Java quick start service from command line. ...

Simple interpreter to embed and extend inside an C++ Windows application

I need a simple interpreter which will do execution (evaluation) of simple expressions/statements and also call functions from main C++ applications. At the moment I do not need scripting of the application, but it may be useful later. It should also be strait-forward for other team members to pull my application from Source Repository ...

Embedding LuaInterface in C# has a poor performance?

I've embedded the LuaInterface project into an application written in C# using .NET Framework 4.0. After compiling LuaInterface and Lua 5.1 I've referenced them in my application and created a Lua VM and exposed a few .NET classes. When the Lua VM doesn't make many calls, performance is not affected at all; but when it starts to call a l...

Javascript not executing when placed in external script file

I'm building an ASP.NET MVC site where I need a tag editor, similar to the one used on Stack Overflow. I've already looked up how to accomplish the necessary autocompletion with jQuery UI, but I've run into a problem: when I place the script in an external .js file, it doesn't execute. Here is my test.html: <html> <head> <meta ch...

Using Rails to build a GUI for an existing CLI Ruby script?

G'day guys, Currently having a bit of a philsophical conundrum. Myself and a few mates have built a quite awesome ruby CLI script for parsing and managing data. It uses gems, responds to requests and is fully functional and great. I was wondering if there was any way I could hold a singleton instance of this class and interact with it...

Using shell script to insert data into remote MYSQL database

I've been trying to get a shell(bash) script to insert a row into a REMOTE database, but i've been having some trouble :( The script is meant to upload a file to a server, get a URL,HASH, and a filesize, connect to a remote mysql database, and insert the data into an existing table. I've gotten it working until the remote MYSQL database...

Writing a script file to create a new folder based on the current date

Hello, CentOS 5.3 I have a script file that works for backing up a repository and I am using rsync to copy the contents to the source directory. I have a crontab job that runs every night at 12am that calls my script file. repos_backup.sh rsync -razv [email protected]:repos /home/backup_sys_user/repos_backup However, this puts all th...

How to echo text and have output from a command be sent to a file in parallel

I would like to echo text and also remotely ping a computer and have the output be sent to a log file. I also need to do this in parallel but I am having some trouble with how the output is being sent into the log file. I would like the output to look like: host | hostTo | result of ping command but since I have this running as a back...

GolfScript: A Practical Example

Has anyone used GolfScript for a serious project aside from CodeGolf? Perhaps you could give an example. I am curious to learn it and I am wondering if its worth my time or if its just a hobby language? When I search stackoverflow.com I can only find CodeGolf examples of the language. In some sense it reminds me when I first learned Per...

Good scripting language/framework for recreating polynomial root calculator

I was just wondering what the best online scripting language is to use for "simple" mathematical calculations, like solving for roots in 2nd 3rd or 4th degree polynomials. For example, creating a little web "applet" like the one found here which inserts the values inputed into the text boxes and inputs them as variables into the "quadra...

Can I execute a single C# statement as a script?

Hello everyone! I have seen online how C# allows you to compile code on the fly and I think that is a really awesome thing. I need to use this functionality for my project. But here is the problem. I'm not trying to compile a whole function or new program dynamically. I just need to call a single statement to create or delete stuff on th...

VBA: How to display an error message just like the standard error message which has a "Debug" button?

As usual, I create an error-handler using On Error Goto statement, there I put a few lines of cleaning codes and display the error message, but now I don't want to lose the comfortableness of the default handler which also point me to the exact line where the error has occured. How can I do that? Thanks in advance. ...

How can I get user input (via a dialog window) in a Windows script?

I'd like to create a simple search script that runs from the CMD prompt. It needs to asks for user input first e.g. "what to search". How can I prompt the user for input (in cmd), or open a input dialog (in any standard scripting Windows language). ...

How to write an xcode user script to surround the string the cursor is inside with NSLocalizedString(<string>, nil)

Hi all, I'm trying to figure out the best way to automatically add NSLocalizedString() around a string in xcode. Ideally I'd like a way that I could position the cursor within @"foo", press a key binding, and it'd be turned into NSLocalizedString(@"foo", nil). I've had a look at the documentation for user scripts and can't see an obvi...

Javascript: which function structure to use

Hey guys, I was reading an article about Javascript's best practices, and kinda got confused about which function structure to use... I guess it might have an impact on the scope of the variables and functions, but which one of these structures would you use (and which is considered the best practice)? Structure 1: use the object lit...

how do I cancel visual mode programmatically in vim

I'm running a bit of code in Vim and having a problem (I think) with not being in the correct mode. I'm trying to get the text between either '< >' or '[ ]' into a register. At point code starts below I know the cursor is between a pair of brackets, but I don't know what kind the brackets are: " put text in x reg if I'm in <> brac...