shell

What's a good company for simple, shell hosting?

My old shell host (StrayNet) is closing up, and I'd like to find a decent, relatively cheap Unix shell host that offers: a couple of background processes email, irc, etc., an IP address or vhost. For the record, I do have a Slicehost slice, so I'm not looking for anything to host a project. I just like having a third location to pin...

How to best capture and log scp output?

I am trying to capture output from an install script (that uses scp) and log it. However, I am not getting everything that scp is printing out, namely, the progress bar. screen output: Copying /user2/cdb/builds/tmp/uat/myfiles/* to server /users/myfiles as cdb cdb@server's password: myfile 100% |******************...

Is there a way to change another process's environment variables?

On Unix, is there any way that one process can change another's environment variables (assuming they're all being run by the same user)? A general solution would be best, but if not, what about the specific case where one is a child of the other? Edit: How about via gdb? ...

What Linux/Unix commands are outdated and have powerful alternatives?

Today I discovered you can make less act like tail -f. less filename, then press Shift-F to start follow mode. Just like tail, but you have all the added features of less - like scrolling, searching, and the highlighting of search hits. I've been watching log files with tail for years. This just made me ponder: are there other comm...

Equivalent of %~dp0 in sh

I'm converting some Windows batch files to Unix scripts using sh. I have problems because some behavior is dependent on the %~dp0 macro available in batch files. Is there any sh equivalent to this? Any way to obtain the directory where the executing script lives? ...

Unix: Getting Export PATH to "Stick"

When setting the export path in Unix, example: export PATH=$PATH: $EC2_HOME/bin If I quit terminal and open it back up to continue working, I have to go through all the steps again, setting up the paths each time. I'm wondering how I can set the path and have it "stick" so my system knows where to find everything the next time I open ...

Can I use Python as a bash replacement?

I currently do my textfile manipulation through a bunch of badly remembered awk, sed, bash and a tiny bit of Perl. I've seen mentioned a few places that python is good for this kind of thing, I know a little and I would like to know more. Is python a good choice for this, and is there a good book or guide to learning how to use python t...

Using os.execvp in Python

I have a question about using os.execvp in Python. I have the following bit of code that's used to create a list of arguments: args = [ "java" , classpath , "-Djava.library.path=" + lib_path() , ea , "-Xmx1000m" , "-server" , "code_swarm" , params ] When I output a string using ...

Hidden features of Bash

Shell scripts are often used as glue, for automation and simple one-off tasks. What are some of your favorite "hidden" features of the Bash shell/scripting language? One feature per answer Give an example and short description of the feature, not just a link to documentation Label the feature using bold title as the first line See al...

How to read mutliline input from stdin into variable and how to print one out in shell(sh,bash)?

What I want to do is the following: read in multiple line input from stdin into variable A make various operations on A pipe A without loosing delimiter symbols (\n,\r,\t,etc) to another command The current problem is that, I can't read it in with read command, because it stops reading at newline. I can read stdin with cat, like thi...

How do I print a field from a pipe-separated file?

I have a file with fields separated by pipe characters and I want to print only the second field. This attempt fails: $ cat file | awk -F| '{print $2}' awk: syntax error near line 1 awk: bailing out near line 1 bash: {print $2}: command not found Is there a way to do this? ...

How can I use negative wildcards in a unix/linux shell?

Say I want to copy the contents of a directory excluding files and folders whose names contain the word 'Music'. cp [exclude-matches] *Music* /target_directory What should go in place of [exclude-matches] to accomplish this? ...

Keeping shell configurations in sync across multiple machines

I'm a pretty active command line user and I have shell accounts all over the place. MacBooks, Linux desktop machines, Linux servers, Cygwin on XP, you name it. How can I keep my shell configuration (.bashrc, .vimrc etc.) in sync across all these machines using the limited tools available across all platforms? I have been using rsync in...

Seething over MSYS shell - is it replaceable?

I need a serviceable shell for MSYS. This is my current dilemma: The default rxvt.exe has a scroll bar and copy and paste, but doesn't send control characters or arrow keys to a running program in the shell (like interpreters/debuggers). This is a real thorn when using the Haskell interpreter ghci. The other shell sh.exe handles con...

Redirect Stdin and Stdout to File

I'm currently the Teaching Assistant for an Introduction to C class. The class is being taught using Visual Studio, but when grading I just use a simple Windows batch script to process all the assignment submissions, compile them, run them on a test file, and redirect the output to a series of text files I can print out, mark up, and han...

Can you rename a shell session by command in linux?

I like to keep my shell sessions named with useful titles as I work, this helps me keep track of what I'm using each of the many tabs for. Currently to rename a session I double click its name on the tabbed part of the console - is there any command that I can use to do this from within the shell? It would save me a bit of time. thanks...

grep --exclude/--include syntax (do not grep through certain files)

I'm looking for the string "foo=" (without quotes) in text files in a directory tree. It's on a common Linux machine, I have bash shell: grep -ircl "foo=" * In the directories are also many binary files which match "foo=". As these results are not relevant and slow down the search, I want grep to skip searching these files (mostly JPE...

what's a more concise way of finding text in a set of files?

I currently use the following command, but it's a little unwieldy to type. What's a shorter alternative? find . -name '*.txt' -exec grep 'sometext' '{}' \; -print Here are my requirements: limit to a file extension (I use SVN and don't want to be searching through all those .svn directories) can default to the current directory, bu...

C Shell: How to execute a program with non-command line arguments?

My $SHELL is tcsh. I want to run a c shell script that will call a program many times with some arguments changed each time. The program I need to call is in Fortran; I don't want to edit it. The program only takes arguments once the it is executed, but not on the command line. Upon calling the program in the script the program take...

Provide password using Shell script

I had setup my clients & server for passwordless login. Like passwordless login by copying RSA key of server to all client's /root/.ssh/id-rsa.pub. but this, I have done manually. I like to automate this process using shell script and providing password to the machines through script. If this problem is solved then I also want to use rsy...