scripting

How to discover the machine type?

Hi, I would like to discover the machine architecture type of a big number of machines. I have the hostname of each machine. The machines have Debian 4 linux, SunOS 9, SunOS 10 or Apple Darwin. All are unix-like, but with minor differences. I would like to know: - architecture (x86, x86_64, ia64, sparc, powerpc...) - processor type (in...

Submitting form fails when the form data contains a <script> tag LAMP

We have a hosted site that has a CMS we built running on a LAMP stack. We noticed that when you save HTML that has a tag embedded in the HTML the request immediately dies. This does not occur on the staging or local development instances of the CMS, so I'm assuming its a server configuration issue. Any ideas what might cause this behavi...

How to capture stderr on Windows/DOS ?

I want to capture the errors from a script into a file instead of to the screen. In *nix, this is done with stderr redirection, usually echo "Error" 2> errorfile.log How do I do it in CMD script under windows? Thanks! Miki ...

Scripting languages

What is it about scripting languages that makes them so easy to do rapid prototyping? Is it just that they are not statically typed? I am a C# programmer, and have had not much experience with javascript or python .. or any of the other scripting languages out there. The more i read about them the more i feel that they may be the answe...

VimL Script language: what is an acceptable alternative?

Problem: One of my favorite aspects of Vim is its flexibility. One of my least favorite is the VimL script language itself. I know everyone has his or her own preference for languages and editors, so I take it for granted that not everyone agrees with me. Question: If you are a Vim user, and if you have had a similar disaffection for us...

What's the correct/proper way to test if an object is a jQuery object in javascript?

I'm writing a javascript function and in "compact" javascript design fashion, the type/length of arguments changes the behaviour of the function. One possible type of the argument is a jQuery object, for which I would like very special logic. What is the best way to test if an object is an instance of jQuery? ...

Making a C++ app scriptable

I have several functions in my program that look like this: void foo(int x, int y) Now I want my program to take a string that looks like: foo(3, 5) And execute the corresponding function. What's the most straightforward way to implement this? When I say straightforward, I mean reasonably extensible and elegant, but it shouldn't t...

file offsets on windows

Is there an easy way, preferably with a scripting language or a small tool that could be called through a batch file, to operate on a text file, mark an offset, and put everything after the offset into a new file? I have a text file added to nightly, and I would like to make it so that the end of the file is marked, then after new data ...

How can I make a Windows batch-file which changes an environment variable?

Is it possible to make a batch file which can make a persistent change to an environment variable? For example my installer.bat script copies some files to a random location in the computer's file-system. I'd like to add that location to the PATH environment variable so that the programs can be run in the current session. FYI - the st...

Can a python script persistently change a Windows environment variable? (elegantly)

Following on from my previous question, is it possible to make a Python script which persistently changes a Windows environment variable? Changes to os.environ do not persist once the python interpreter terminates. If I were scripting this on UNIX, I might do something like: set foo=`myscript.py` But alas, cmd.exe does not have anyt...

How to hide the console of batch scripts without losing std err/out streams

My question is similar to Running a CMD or BAT in silent mode, but with one additional constraint. If you use WshScript.Run in vbscript, you lose access to the standard in/error/out streams of the process. WshScript.Exec gives you access to the standard streams, but you can't hide your windows. How can you have your cake (hide the win...

Unix Shell scripting for copying files and creating directory

I have a source directory eg /my/source/directory/ and a destination directory eg /my/dest/directory/, which I want to mirror with some constraints. I want to copy files which meet certain criteria of the find command, eg -ctime -2 (less than 2 days old) to the dest directory to mirror it I want to include some of the prefix so I know ...

What is the best/easiest way to use nested switch/case statements?

What is the better practice of the following two switch/case statements? Is there an easier way (less code) to do this? switch (myValue) { case 1: { methodFor1(); break; } case 2: case 3: { methodFor2or3(); if (myValue == 2) methodFor2(); if (myValue == ...

AppleScript to launch a pkg file from another package

Hi I want to run a pkg file added as a component in my package based on certain conditions. How can I run the pkg file from AppleScript? Thanks? Edit: I am now able to run the pkg file using open pkgFile.pkg I want to embed this AppleScript as part of a package along with some other packages as the components of this pakage. Where do ...

When should I add a GUI?

I write many scripts at home and on the job. Most of the time the scripts get used only a few times to accomplish their chosen task and then are never used again. However, sometimes I write a script to do something more complicated, something that requires user input. It is at this point that I usually agonize over whether to implemen...

How do you modify existing SharePoint sites?

I often have customer requesting changing properties, like the version history setting on all document libraries on all existing sites on a farm. So far the best solution I have been able to think of is to script it in Powershell, test the script before I run it, and then pray that I have not overlooked something critical. Is there a be...

Executing linux commands with PHP

I'm trying to execute a linux command through a PHP command-line script, which is no problem using the exec command. The problem is, the command I am executing (mysqldump) outputs an error message if something is wrong (for example user/password is incorrect). I can't seem to be able to capture this error in order to log it. It just pri...

Does anyone know of a good alternative to Pipe Viewer for Windows Platform?

If you do not know what Pipe Viewer is (I did not know about it until 5 minutes ago), then this blog does a good job giving a brief introduction to it with some examples. I write a lot of Perl Scripts as an ETL developer and a lot of times, the files that I work with take really long time to operate with (unzipping, moving, etc). Therefo...

Text Editor with Scripting...for Linux

For a while now, I have been using UltraEdit on my Windows box. The ability to write scripts with a familiar language (JavaScript) has proved to be extremely useful. The only problem is that I cannot use it on my Linux box at work. Is there a comparable text editor that runs on Linux and has an integrated scripting engine? Not breaki...

python chdir to dir the py script is in

How do i chdir to the directory that the python script is in? so far i figured out os.chdir and sys.argv[0]. I'm sure there is a better way then to write my own func to parse argv[0] ...