shell

How do I declare a shell command in .NET setup project, and launch it after (or before) product installation ?

I would like to launch a shell command after an installation made with a .NET setup project under VS2008, and another shell command before start an uninstall, always from .NET msi package. How can I do it ? ...

documenting shell scripts' parameters

Is there a convention for documenting shell scripts' parameters? For example: #!/usr/bin/env bash # <description> # # Usage: # $ ./myScript param1 [param2] # * param1: <description> # * param2: <description> A few things I don't like about this particular template: the script's file name (myScript) appears within the file itself ...

Remembering terminal states in OS X (like Fluid for the shell...)

I have a few different things open in the terminal whenever I'm developing -- log tailing, Ruby console, plain shell in a certain directory, and so on. How do I: start all those things at once, hopefully in the right position on the screen? make them distinct so I can switch to them with Quicksilver / Alt-Tab? Fluid solved this pro...

Associative arrays in Shell scripts

We required a script that simulates Associative arrays or Map like data structure for Shell Scripting, any body? ...

What are replacement and new practices from sh to Bash?

As someone who did a lot of sh scripting twenty years ago, and now coming back to it again, I find I'm using techniques that are considered obsolete. I should take the time to read the "What's new", but I don't. and it's not terribly efficient. Examples: Instead of use tmpfile=/tmp/me$$ tmpfile=`mktemp` [ ] ...

How can I get something to (really) run AfterPublish using MSBuild

I need to shell out (to call svn commit on my .application file) after a ClickOnce publish. However I've not been able to find a way to hook it into my MSBuild .csproj file. The PostBuild Event is too early And calling 'start Some.exe' in PostBuild does not run in the background And using the AfterBuild Target from MSBuild is done befo...

How to close a shelled process in VB6

I shell out an application from my VB6 app. I would then like to close it. How can I pull this off? ...

Best way to choose a random file from a directory in a shell script

What is the best way to choose a random file from a directory in a shell script? Here is my solution in Bash but I would be very interested for a more portable (non-GNU) version for use on Unix proper. dir='some/directory' file=`/bin/ls -1 "$dir" | sort --random-sort | head -1` path=`readlink --canonicalize "$dir/$file"` # Converts to ...

formatting shell output into structured data?

Are there any libraries (perl, python, ruby, etc) or other means of formatting the output of shell commands to a structured data format like JSON or XML to be processed by another application? Use case: Bunch of CentOS servers on a network. I'd like to programatically login to them via SSH, run commands to obtain system stats and eventu...

Calendar calculations in bash

Hi. I want to do some calendar manipulations in bash - specifically, I want to figure out the last date of a given month (including leap-year, and a preparing a table for a lookup is not a valid solution for me). Supposedly I have the following code: $year=2009 $start_month=2 $end_month=10 for $month in $(seq $start_month $end_month); ...

Why is this bash prompt acting strangely/disappearing, and how do I fix it (OS X)?

I admit that I use a somewhat long-winded bash prompt: --(username)-(Wed April 01|12:00:00)--(~ $ Recently, I got the bright idea to change it so that depending on the exit value from the previous command, if success, the interior elements of the ()'s would be green, and if failure, they would be red. I got it working for the most par...

How to run two processes as though they were one in bash?

hi, I've got two commands foo and bar. foo runs for a long time without stdin or stdout/stderr activity. bar is a client of foo and runs with stdout/stderr but no stdin activity. I'd like to run them from one shell, being able to kill both with ctrl-c, and to see the output from bar as it occurs. i.e. something like this sequence fo...

How to execute an arbitrary shell script and pass multiple variables via Python?

I am building an application plugin in Python which allows users to arbitrarily extend the application with simple scripts (working under Mac OS X). Executing Python scripts is easy, but some users are more comfortable with languages like Ruby. From what I've read, I can easily execute Ruby scripts (or other arbitrary shell scripts) us...

What is an easy way to do a sorted diff between two files?

I have two files in which some of the lines have changed order. I would like to be able to compare these. One website suggested something that looks like this: diff <(sort text2) <(sort text1) But this yields the error: Missing name for redirect. I am using tcsh. Is the command above for a different shell? Is there a better way? ...

How to capture the result of a system call in a shell variable?

We want to build a script that run every night (kills and restart a java process). For that we need to capture the process number (since there could be more than one java process running). The command below is basically what we will use to obtain the processes number, probably with a regexp at the end of the grep. Unless any better su...

How to get the newly-installed version within a Debian postinst script?

Per the Debian Policy Manual, my postinst script is getting called at upgrade and configure time, as "postinst configure old-version", where old-version is the previously installed version (possibly null). I want to determine new-version, i.e. the version that is currently being configured (upgraded to). The environment variable $DPKG_...

Is there a better Windows command-line shell?

CMD.EXE is posing lots of problems for me. I have Cygwin installed and use bash regularly, and I also have the mingwin bash shell that comes with mSysGit, but sometimes I really do need to run things from the Windows shell. Is there a replacement for the Windows shell that: has a persistent command-line history, available in my next ...

How to insert a newline in front of a pattern?

Not how to insert a newline before a line. This is asking how to insert a newline before a pattern within a line. For example, sed 's/regexp/&\n/g' will insert a newline behind the regexp pattern. How can I do the same but in front of the pattern? Here is an example input file somevariable (012)345-6789 Should become some...

Variable value inconsistency on BASH and CSH

May God never give you the bane of working on Solaris. Now, I am trying to run this simple shell script: #!/bin/sh input="a b c" data="123" while read eachline do data="$data$eachline" done << EOF $(echo "$input") EOF echo "$data" exit 0 On RHEL(BASH) I receive output as expected i.e "123abc", however, on Solaris I receiv...

Bash TAB-completion inside double-quoted string

Problem I'm writing a Twitter client for the command line (in C). I'm currently working on doing TAB-completion for Twitter screen names, like so: tweet "@s<TAB> @sourcebits @spolsky However, I can't get it to work mid-string, e.g.: tweet "Foo bar @s<TAB> since Bash treats the string as one word. I couldn't find anythin...