shell

How to open files from explorer into different tabs.

How to open files from explorer into different tabs. I can associate an open with menu with the file type, now when I already have the program working, how to open the new file into another tab, instead of new program. How to find the already running process exactly, not with the name and send the filename to it. Let me make myself clea...

Is BitTorrent good for copy files between servers in the workplace?

I have 1 source server that contains about 30GB of files that I want to copy to 7 other servers. I currently SCP the files over to the first four servers and when that transfer is complete SCP to the last 3 servers. Would using BitTorrent be faster to distribute the files to all 7 at once? The connection internally is already fast and...

unix shell nightmares

What are the worst/best unix shell nightmares? My favourites are: rm -rf / tmp/foo (deletes everything if you are root; typo :-( ) rm -rf .* (deletes everything if you are root; not just all hidden files) Files in * that are used as parameters, e.g. after touch -- -rf, rm * eventually evaluates to rm -rf foo bar cat foo | sed 's/foo/ba...

Awk appears to disconnect my DB2 session when piping

Hello. I'm attempting to run the following command in Korn Shell (ksh): set -A INDEXES `db2 "describe indexes for table ${TABSCHEMA}.${TABNAME} show detail" | awk '{print $1"."$2}'` What I'm attempting to achieve is place a list of the indexes over a particular table into an array which I can later iterate through. The problem is, w...

AJAX - Progress bar for a shell command that is executed

I am making use of AJAX on my site and I would like to show users progress of a file that is being downloaded by my server. The download is done by script that outputs a percentage to the shell. I would like to pass this info back to the user using AJAX. How can I do this? Thank you for any help and direction. I hope your solutions do...

Add last n lines of files to tar/zip

I need to regularly send a collection of log files that can grow quite large, so I would like to only send the last n lines of the each of the files. for example: /usr/local/data_store1/file.txt (500 lines) /usr/local/data_store2/file.txt (800 lines) Given a file with a list of needed files named files.txt, I would like to create an...

cygwin interop questions

A quick couple of Cygwin questions that I am not quite sure how to search in order to find the answer myself: Question: When I run which perl on my cygwin installation, it doesn't point to my pre-installed windows installation, it points to the cygwin one. How can i change it so it points to my windows based perl installation: /cygd...

Bash Scripting - shell command output redirection

Hi all, Can someone help explain the following: If I type: a=`ls -l` Then the output of the ls command is saved in the variable a but if I try: a=`sh ./somefile` The result is outputed to the shell (stdout) rather than the variable a What I expected was the result operation of the shell trying to execute a scrip 'somefile' to b...

Search and replace in Shell

I am writing a shell (bash) script and I'm trying to figure out an easy way to accomplish a simple task. I have some string in a variable. I don't know if this is relevant, but it can contain spaces, newlines, because actually this string is the content of a whole text file. I want to replace the last occurence of a certain substring w...

Insert Command into Bash Shell

Is there any way to inject a command into a bash prompt in Linux? I am working on a command history app - like the Ctrl+R lookup but different. I am using python for this. I will show a list of commands from history based on the user's search term - if the user presses enter, the app will execute the command and print the results. So fa...

AJAX Progress: Reading output from the Shell

Hello all, Objective: Make a progress bar where users can check how much of a file has been downloaded by my server. Scenario:I have a PHP script that executes a python script via popen. I have done this like so: $handle = popen('python last', 'r'); $read = fread($handle, 4096); pclose($handle); This python script outputs to the s...

How to run Unix shell script from java code?

It is quite simple to run a Unix command from java. Runtime.getRuntime().exec(myCommand); But is it possible to run a Unix shell script from java code? If yes, would it be a good practice to run a shell script from within java code? ...

Finding processes using ALSA sound fast

Currently the way /usr/sbin/alsa in Debian knows the processes using the sound card looks like: echo $( \ lsof +D /dev -F rt \ | awk '/^p/ {pid=$1} /^t/ {type=$1} /^r0x(74|e)..$/ && type == "tCHR" {print pid}' \ | cut -c 2- \ | uniq \ ) Which is rather ugly and depends on lsof. I am looking for a POSIX solution without lsof, perha...

Best way to do a find/replace in several files?

Hey dudes, what's the best way to do this? i'm no command line warrior, but i was thinking there's possibly a way using grep and cat. i just want to replace a string that occurs in a folder and sub-folders. what's the best way to do this? i'm running ubuntu if that matters. -d ...

Python Script: Print new line each time to shell rather than update existing line

Hello, I am a noob when it comes to python. I have a python script which gives me output like this: [last] ZVZX-W3vo9I: Downloading video webpage [last] ZVZX-W3vo9I: Extracting video information [download] Destination: myvideo.flv [download] 9.9% of 10.09M at 3.30M/s ETA 00:02 The last line keeps getting updated with new values ...

Schedule a Task in Vista - System Restart

Hello, I am trying to write a system restart Task for Windows Vista. I'm a web developer by trade so I'm a little out of my element here. I have got into my OS and discovered Task Scheduler. So far I've been able to set up some various tasks to run small WPF programs by calling the *.exe files. What I really need to do is set up a sys...

Shell output not being fully retrieved by PHP!

I have a PHP script which executes a shell command: $handle = popen('python last', 'r'); $read = fread($handle, 4096); print_r($read); pclose($handle); I echo the output of the shell output. When I run this in the command I get something like this: [root@localhost tester]# python last [last] ZVZX-W3vo9I: Downloading video webpage [la...

Shebang problem

Hello I'm trying to run a python script. It works fine when I run it: python2.5 myscript.py inpt0 The problem starts when I add a shebang: #!/usr/bin/env python2.5 Result in: $ myscript.py inpt0 : No such file or directory Try 2: #!/usr/local/bin/python2.5 Result in: $ myscript.py inpt0 : bad interpreter: No such file or di...

In python 2.4, how can I execute external commands with csh instead of bash?

Without using the new 2.6 subprocess module, how can I get either os.popen or os.system to execute my commands using the tcsh instead of bash? I need to source some scripts which are written in tcsh before executing some other commands and I need to do this within python2.4. EDIT Thanks for answers using 'tcsh -c', but I'd like to avoi...

Programming a terminal emulator, what's in it?

This is related somewhat to this question about a better shell terminal/gui-interface for cmd.exe In my quest to find a better shell terminal, the only useful thing I came across was Console2, other alternatives weren't free and generally didn't offer much more than Console2 to make them worth their price. I can't help but wonder, "how...