shell

AJAX Progress Bar - Polling, Comet?

Hi I would like some advice on how to implement the following: I would like to make my users aware of the progress of a task that is running on my server via AJAX. My server runs a PHP script that downloads a file via shell command using the popen function. It periodically echos/prints what is happening. I would like to capture this ou...

How can I use bash syntax in Makefile targets?

I often find bash syntax very helpful, e.g. process substitution like in diff <(sort file1) <(sort file2). Is it possible to use such bash commands in a Makefile? I'm thinking of something like this: file-differences: diff <(sort file1) <(sort file2) > $@ In my GNU Make 3.80 this will give an error since it uses the shell instead...

Redirect STDERR / STDOUT of a process AFTER it's been started, using command line?

In the shell you can do redirection, > <, etc., but how about AFTER a program is started? Here's how I came to ask this question: a program running in the background of my terminal keeps outputting annoying text. It's an important process so I have to open another shell to avoid the text. I'd like to be able to >/dev/null or some other...

How can I print intermediate results from a pipeline to the screen?

Duplicate http://stackoverflow.com/questions/570984/how-can-i-gzip-standard-in-to-a-file-and-also-print-standard-in-to-standard-out I'm trying to count the lines from a command and I'd also like to see the lines as they go by. My initial thought was to use the tee command: complicated_command | tee - | wc -l But that simply doubles ...

How do you determine what bash ls colours mean?

When you perform ls in a bash shell, sometimes there are colours to indicate different resource types, and you can enable/control this with the --color argument. But neither the man page nor Google is providing an answer to the question: What do these colours indicate by default, and how do I display what the current system uses? UP...

How do I run command line "explorer /n, /select,(filename)" in c++ builder?

I've tried shellexecute, I've tried createprocess, I can't seem to get this to do anything. Running the command line manually (at the actual command prompt in a console window) works, but nothing I've tried so far will run it from within a c++ builder app. Obviously (filename) is just a place holder. It would be given a valid file n...

Calculate size of files in shell

I'm trying to calculate the total size in bytes of all files (in a directory tree) matching a filename pattern just using the shell. This is what I have so far: find -name *.undo -exec stat -c%s {} \; | awk '{total += $1} END {print total}' Is there an easier way to do this? I feel like there should be a simple du or find switch th...

Batch Renaming with Bash

How can Bash rename a series of packages to remove their version numbers? I've been toying around with both expr and %%, to no avail. Examples: Xft2-2.1.13.pkg becomes Xft2.pkg jasper-1.900.1.pkg becomes jasper.pkg xorg-libXrandr-1.2.3.pkg becomes xorg-libXrandr.pkg ...

Executing an interactive shell script remotely from a web GUI

There's a requirement in my project to execute interactive shell scripts remotely through a web GUI. This means that stuff printed to the standard output of the script has to be made available on the GUI, and the user input has to be taken from the GUI and written to the standard input of the script. My questions are (a) Is this is a go...

print time in batch file (milliseconds)

How do I print the time (in ms) in a Windows batch file? I want to measure the time that passes between lines in my batch file, but Windows's "time /T" does not print milliseconds. Is there a tiny 3rd party command line utility that does this perhaps? echo %time% won't help because it's evaluated just once and thus prints the same tim...

SSH to debian server instantly logs out

I'm trying to help someone with their Debian server. They have Plesk. I made myself an user with Plesk and enabled SSH access. I can log on ... but only for one second. I see the MOTD, I see a Debian disclaimer, then I'm logged out again. "Connection closed". The only thing I could think to try is to change the shell settings, Plesk h...

problem while running shell script using java

Hi, I have a shell script named test.sh in /tmp/padm folder. In that shell script I have a single statement echo "good" I am trying to run the shell script using Java code. String cmd=("/tmp/padm/.test.sh"); Runtime rt = Runtime.getRuntime(); Process pr=rt.exec(cmd); But my problem is that I am not able to see "good" w...

flush output in Bourne Shell

I use echo in Upstart scripts to log things: script echo "main: some data" >> log end script post-start script echo "post-start: another data" >> log end script Now these two run in parallel, so in the logs I often see: main: post-start: some data another data This is not critical, so I won't employ proper synching, but th...

How to perform calculation over a log file

I have a that looks like this: I, [2009-03-04T15:03:25.502546 #17925] INFO -- : [8541, 931, 0, 0] I, [2009-03-04T15:03:26.094855 #17925] INFO -- : [8545, 6678, 0, 0] I, [2009-03-04T15:03:26.353079 #17925] INFO -- : [5448, 1598, 185, 0] I, [2009-03-04T15:03:26.360148 #17925] INFO -- : [8555, 1747, 0, 0] I, [2009-03-04T15:03:26.367523...

errors while running the shell script

WARNING: error instantiating 'java.util.logging.FileHandler,' referenced by handlers, class not found java.lang.ClassNotFoundException: java.util.logging.FileHandler, at java.lang.Class.forName(libgcj.so.7rh) at java.util.logging.LogManager.locateClass(libgcj.so.7rh) at java.util.logging.LogManager.createInstance(libgcj.so.7rh) ...

How can I cut(1) camelcase words?

Is there an easy way in Bash to split a camelcased word into its constituent words? For example, I want to split aCertainCamelCasedWord into 'a Certain Camel Cased Word' and be able to select those fields that interest me. This is trivially done with cut(1) when the word separator is the underscore, but how can I do this when the word i...

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". ...

Egrep acts strange with -f option

Hi all, I've got a strangely acting egrep -f. Example: $ egrep -f ~/tmp/tmpgrep2 orig_20_L_A_20090228.txt | wc -l 3 $ for lines in `cat ~/tmp/tmpgrep2` ; do egrep $lines orig_20_L_A_20090228.txt ; done | wc -l 12 Could someone give me a hint what could be the problem? No, the files did not changed between executions. The expected ...

Why does using Shell to run a .MSI file sometimes fail in VB6?

I am attempting to launch the .NET CF installer from a VB6 app using the following code (for the sake of brevity I have replaced the full path to the installer with "(full path)"): Shell "C:\WINDOWS\system32\msiexec.exe /fa ""(full path)\NETCFSetupv35.msi""" I've run this on four machines so far. On two it works fine, on the other tw...

Should I escape shell arguments in Perl?

When using system() calls in Perl, do you have to escape the shell args, or is that done automatically? The arguments will be user input, so I want to make sure this isn't exploitable. ...