scripting

Useful PowerShell one liners

Provide one line PowerShell script that you found useful, one script per answer please. There is a similar question here, but this one gives only links to pages with scripts, lets answers one by one here and have a contributed list of most frequently used or most useful scripts. 1.List most recent version of files ls -r -fi *.lis | s...

With Bash Scripting, how can I suppress all output from a command?

I have a bash script that runs a program with parameters. That program outputs some status (doing this, doing that...). There is no option for this program to be quiet. How can I prevent the script from displaying anything? I am looking for something like windows "echo off". ...

Script to change Action Sequence records in an MSI

To solve a problem listed here I've got to change the InstallExecuteSequence .RemoveExistingProducts record in an MSI. I want to do this as part of the build process rather than mucking around with Orca ...

cmd script that fails when text is found

In the windows shell: echo "foo bar" | find "foo" succeeds (i.e. errorlevel = 0). However, I want a script that fails (i.e. errorlevel <> 0) when it finds a particular word in some input text. Any ideas? ...

HTTP request with custom headers fields using Windows Scripts

Is it possible to perform a HTTP Request with specific header fields (like 'referer', 'cookies' or 'User-Agent') using Windows Script Host or any other Windows scripting technology?? Thanks. ...

one week information of alertlofile

Hi I want to view the ORA errors in alertlogfile of past 7 (monday-sunday)days, by writting in shell scripts. Can anybody help me. Thanks ...

Checking duplicates in terminal?

The following code prints me a long list of files with hashes and file names md5sum *.java I have tried unsuccessfully to list the lines where identical hashes occur, so that I can then remove identical files. How can you filter and delete identical files which have same content? ...

Abandon Long Processes in PHP (But let them complete)

I have an HTML form that submits to a PHP page which initiates a script. The script can take anywhere from 3 seconds to 30 seconds to run - the user doesn't need to be around for this script to complete. Is it possible to initiate a PHP script, immediately print "Thanks" to the user (or whatever) and let them go on their merry way while...

How do I write a batch file to delete folders and files on a time basis?

Exact Duplicates: How to write a batch file to delete the files which are 5 days or older from a folder? write a batch file to delete 6 days older files from a folder write a batch file to delete 5 daya older files from a folder How do I create a batch script that will delete a folder on a scheduled basis? write a batch file to remove ...

Embedding a Ruby interpreter in a C++ app

I'm hoping to use Ruby as a scripting language for my game engine. I've found the usual articles describing how to call Ruby classes from C++ code and vice versa (e.g. here) but I can't quite see how to do what I want with that way of working... My engine currently uses a little language I wrote myself with Flex and Bison, and a little ...

How can I ssh directly to a particular directory?

I often have to login to one of several servers and go to one of several directories on those machines. Currently I do something of this sort: localhost ~]$ ssh somehost Welcome to somehost! somehost ~]$ cd /some/directory/somewhere/named/Foo somehost Foo]$ I have scripts that can determine which host and which directory I need t...

Programatically compare file sizes in linux

I have two versions of a very large and complicated directory structure with tens of thousands of individual files and I want to look for significant file changes from one version to another. Each and every file has changed in some minor way. For example you might have a file called intro.txt which would contain [Build 1057 done by Mi...

Choices for native windows scripting

What is a good windows/xp or Vista scripting language that would provide basic functionality similar to what ksh or bsh does for unix? looking to do simple/quick tasks, build parameters, call executables (.exe), redirect output. Thanks. ...

Vim: Use an expression as a filename

I'm doing some debugging, which involves checking logfiles name "blah N.log" where N is an integer. Periodically, a new log file gets added, and I'd like to just skip to the next log file, rather than explicitly do :e blah\ N.log. I can't just do % vim *.log and then :n, b/c not all the log files exist yet. I've got an expression that...

Bash history re-runs: possible command to avoid using !bang! ?

Scenario: You are doing your daily Bash shell stuff. You want to run a previous command so you type: history | grep foocommand Then you get a list of all the foocommand stuff you did for however long your history has kept track, in a list like so: 585 foocommand --baz --bleet 750 foocommand | grep quux 987 history grep | fooco...

How to code in the unix spirit? (small single task tools)

Hello, I have written a little script which retrieves pictures and movies from my camera and renames them based on their date and then copies them on my harddrive, managing conflicts automatically (same name? same size? same md5?) Works pretty well. But this is ONE script. From time to time I need to check if a picture is already hidde...

What language features are needed for game scripting?

I am looking into designing a game scripting language and was wondering what people employed in the games industry considered essential items/properties for a good game scripting language. This includes things like: static vs dynamic types Who should it be aimed at: programmers or designers? syntax(must it look like C?) How high level...

How do I tell if a file does not exist in bash?

I've used the following script to see if a file exists: #!/bin/bash FILE=$1 if [ -f $FILE ]; then echo "File $FILE exists." else echo "File $FILE does not exist." fi What's the correct syntax to use if I only want to check if the file does not exist? #!/bin/bash FILE=$1 if [ $FILE does not exist ]; then echo "File $FILE do...

How can I automate creating IIS script mappings

I would like to automate the following task with a script to create an IIS script mappings for my project: Go to Control Panel | Administrative Tools Open Internet Information Services Right-click the Default web site and select Properties. In the Properties dialog-box select the 'home Directory' tab. Click on the configuration button ...

How to rename files on a date base in the shell?

I'd like to rename some files that are all in the same directory. The file name pattern used is Prefix_ddmmyy.tex with a european date format. For the sake of readability and the ordering I'd like to rename the files in a pattern Prefix_yymmdd.tex with a canonical date format. Anyone ideas how I can do this automatically for a complete ...