shell

How to make a failing $(shell) command interrupt Make

I have a Makefile that starts by running a tool before applying the build rules (which this tool writes for me). If this tool, which is a python script, exits with a non-null status code, I want GNU Make to stop right there and not go on with building the program. Currently, I do something like this (top level, i.e. column 1): $(info G...

How do I prompt for input in a Linux shell script?

I want to pause input in a shell script, and prompt the user for choices. The standard 'Yes, No, or Cancel' type question. How do I accomplish this at a typical bash prompt? ...

How to tell if a string is not defined in a bash shell script?

If I want to check for the null string I would do [ -z $mystr ] but what if I want to check whether the variable has been defined at all? Or is there no distinction in bash scripting? ...

Setting environment variables in linux using bash

In tcsh, I have the following simple script working: #!/bin/tcsh setenv X_ROOT /some/specified/path setenv XDB ${X_ROOT}/db setenv PATH ${X_ROOT}/bin:${PATH} xrun -d xdb1 -i $1 > $2 My question is, what is the equivalent to the tcsh setenv function in bash? Is there a direct analog? The environment variables are for locating ...

How can I run Cygwin Bash Shell from within Emacs?

I am running GNU Emacs on Windows so entering: M-x shell launches the Windows command-line DOS shell. However, I would like to instead be able to run the Cygwin Bash Shell (or any other non-Windows shell) from within Emacs. How can this be easily done? ...

What's the best practice for changing working directories inside scripts?

Do you think changing directories inside bash or Perl scripts is acceptable? Or should one avoid doing this at all costs? What is the best practice for this issue? ...

How to determine whether a given Linux is 32 bit or 64 bit?

When I type uname -a, it gives the following output. Linux mars 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 i686 i686 i386 GNU/Linux How can I know from this that the given OS is 32 bit or 64 bit? ...

How do I add tab completion to the Python shell?

When starting a django application using python manage.py shell, I get an InteractiveConsole shell - I can use tab completion, etc. Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) When just starti...

Bash script, match on dates like?

I'm writing a script to remove some build artifacts older than 1 week. The files have names in the form artifact-1.1-200810391018.exe. How do I go about removing only the files that are greater than 1 week old, excluding the time in hours and minutes at the end of the date-time-stamp? Currently it is removing all of the files in the ...

Shell script/regex: extraction across multiple lines

I'm trying to write a log parsing script to extract failed events. I can pull these with grep: $ grep -A5 "FAILED" log.txt 2008-08-19 17:50:07 [7052] [14] DEBUG: data: 3a 46 41 49 4c 45 44 20 20 65 72 72 3a 30 32 33 :FAILED err:023 2008-08-19 17:50:07 [7052] [14] DEBUG: data: 20 74 65 78 74 3a 20 00 ...

What is your favorite IPython feature?

I've been learning (and enjoying learning!) Python via the IPython interactive shell recently... What's your favorite feature in IPython? Are there any tips and tricks you've picked up that other people might not know about? ...

The shell dotfile cookbook

I constantly hear from other people about how much of the stuff they've used to customize their *nix setup they've shamelessly stolen from other people. So in that spirit, I'd like to start a place to share that stuff here on SO. Here are the rules: DON'T POST YOUR ENTIRE DOTFILE. Instead, just show us the cool stuff. One recipe pe...

ShellExecute equivalent in .NET

I'm looking for the .NET-preferred way of performing the same type of thing that ShellExecute does in Win32 (opening, printing, etc. for arbitrary file types). I've been programming Windows for over 20 years, but I'm a complete newbie at .NET, so maybe I'm just looking in the wrong places. I'm currently using .NET 2.0 (VS C# 2005), but ...

Why do double-quote change the result

I have a simple linux script: #!/bin/sh for i in `ls $1` do echo $i done In my temp folder are 4 file: a.a, a.aa, a.ab and a.ac When i call ./script temp/*.?? i get: temp/a.aa When i call ./script "temp/*.??" i get: temp/a.aa temp/a.ab temp/a.ac Why do the double quote change the result? ...

Javascript shell?

I know that this question has already been asked HERE but sadly none of the answers suggest a javascript standalone shell that has auto completion. I am reopening this question again, in the hope that some new answers might be found. ...

How do I programmatically send an email in the same way that I can "Send To Mail Recipient" in Windows Explorer?

ShellExecute() allows me to perform simple shell tasks, allowing the system to take care of opening or printing files. I want to take a similar approach to sending an email attachment programmatically. I don't want to manipulate Outlook directly, since I don't want to assume which email client the user uses by default. I don't want to s...

cron jobs change time after DST

My cron job is running an hour later after end of DST. This didn't happen to other user's jobs on the same machine (AIX). What am I doing wrong? ...

Unix C Shell Scripting printf help

Attempting to print out a list of values from 2 different variables that are aligned correctly. foreach finalList ($correctList $wrongList) printf "%20s%s\n" $finalList end This prints them out an they are aligned, but it's one after another. How would I have it go through each item in each list and THEN go to a new line? I want t...

Emacs and cygwin

How can I change my GNUemacs to open up a cygwin terminal rather then a cmd one with the shell command? Closed as duplicate of How can I run Cygwin Bash Shell from within Emacs?. ...

Prevent 'cp' from outputting the file name from a bash script

I have a shell script which copies a few files to the current directory, compresses them, and streams the compressed file to stdout. On the client side I use plink to execute the script and stream stdin to a file. This almost works. It seems that the cp command outputs the file name being copied when its executed from inside the scrip...