shell

How can I kill all shells in Unix at once?

My Mac becomes slow over time. The reason is the huge amount of my shells, such as Bashes and Fishes. Each shell has different PID. Killing shells one by one is too cumbersome. How can I kill them at once? ...

How do I determine if a directory is an NFS mount point in shellscript

I want to write a sh/bash script that can determine whether a particular directory is a mount point for an NFS filesystem. eg something like $ mkdir localdir $ mkdir remotedir $ mount host:/share ./remotedir $ classify_dirs.sh --> localdir is local --> remotedir is an NFS mount point ...

Can I autodiscover parameters to shell or Perl scripts to "meta" program WEB UIs for them?

Is it possible to auto-discover parameters to shell/Perl scripts in order to "meta" program WEB UIs for them? I have a bunch of "legacy" scripts that I'd like to "web wrap". So far I have created a CGI-BIN web app with about 3 parameters that can call a bash/Perl reporting script. But it now occurs to me maybe there is quicker or aut...

Can I execute a shell script from a web page?

My web page uploads a file. Currently it places that file in a directory which is polled by a cron job. If the file is there, a bash script acts on the file. I hate the fact that I am polling. The upload happens perhaps once a week, but the user wants to see results within minutes from their file, so I end up polling every 5 minutes....

Using ShellExecuteEx and capturing standard in/out/err

I'm using ShellExecuteEx to execute a command in C. Is there a way to use ShellExecuteEx and capture standard in/out/err? Note: I don't want to use CreateProcess. ...

Separating 'body' of domain name from extension - DOS shell

Hi, I tried everything possible, but still failed. I thought I got it at the point which I'll post as my final attempt, but still isn't good [enough]. A script is being passed three arguments. Domain name, username and password. But the probles is that I need domain separated in "domain" + ".com" format. Two variables. I tried to split...

Help me make my windows cmd.exe console work more like a Linux terminal

The windows terminal (the user-interface around text-applications like cmd.exe) really sucks. There is so much that the Unix-style terminals do that the windows terminal apparently cannot do, for example what if you want to re-size the window in both dimensions by dragging the border. The Windows terminal only allows you to change it's ...

Running Rake Without Shell Access?

For a RoR installation, is there any way to run rake commands without root access? To put it another way, is there any way to get db:create and db:migrate to be run without root access (perhaps automatically or something)? Or can I run rake commands from a RoR controller? ...

How to execute a command and get output of command within C++?

I am looking for a way to get the output of a command when it is run from within a C++ program. I have looked at using the system() function, but that will just execute a command. Here's an example of what I'm looking for: std::string result = system( "./some_command" ) ; I need to run an arbitrary command and get it's output. I've...

How to test if a given path is a mount point

Suppose do you want test if /mnt/disk is a mount point in a shell script. How do you do this? ...

How to discover the machine type?

Hi, I would like to discover the machine architecture type of a big number of machines. I have the hostname of each machine. The machines have Debian 4 linux, SunOS 9, SunOS 10 or Apple Darwin. All are unix-like, but with minor differences. I would like to know: - architecture (x86, x86_64, ia64, sparc, powerpc...) - processor type (in...

Does it make sense to rewrite Perl and shell scripts in java?

I have a bunch of scripts - some in perl and some in bash - which are used for: Creating a database (tables, indexes, constraints, views) Parsing spreadsheets and loading the data into the database Getting info about a bunch of files and loading that into the database. These scripts are used in conjunction with a much larger applicat...

How can I add a line to a file in a shell script?

I want to add a row of headers to an existing CSV file, editing in place. How can I do this? echo 'one, two, three' > testfile.csv and I want to end up with column1, column2, column3 one, two, three (nb changing the initial CSV output is out of my hands) EDIT: I originally had this as 'using sed' but any standard command w...

Unix Shell scripting for copying files and creating directory

I have a source directory eg /my/source/directory/ and a destination directory eg /my/dest/directory/, which I want to mirror with some constraints. I want to copy files which meet certain criteria of the find command, eg -ctime -2 (less than 2 days old) to the dest directory to mirror it I want to include some of the prefix so I know ...

Can a shell script set environment variables of the calling shell?

I'm trying to write a shell script that, when run, will set some environment variables that will stay set in the caller's shell. setenv FOO foo in csh/tcsh, or export FOO=foo in sh/bash only set it during the script's execution. I already know that source myscript will run the commands of the script rather than launching a new...

Using mplayer to determine length of audio/video file

The following works very nicely to determine the length of various audio/video files: mplayer -identify file.ogg 2>/dev/null | grep ID_LENGTH I want to kill mplayer's output so I can determine the length of many files per second (without resorting to setting another process playing sound and then using -ao oss). ...

How to recursively list all files and directories.

Using the tcsh shell on Free BSD, is there a way to recursively list all files and directories including the owner, group and relative path to the file? ls -alR comes close, but it does not show the relative path in front of every file, it shows the path at the top of a grouping i.e. owner% ls -alR total 0 drwxr-xr-x 3 owner group ...

Send a ping to each IP on a subnet

Is there a command line based way to send pings to each computer in a subnet? Like for (int i = 1;i < 254; i++) ping(192.168.1.i) to enforce arp resolution? ...

Executing linux commands with PHP

I'm trying to execute a linux command through a PHP command-line script, which is no problem using the exec command. The problem is, the command I am executing (mysqldump) outputs an error message if something is wrong (for example user/password is incorrect). I can't seem to be able to capture this error in order to log it. It just pri...

Does anyone offer free email/ssh provisions?

I wish to learn the UNIX SHELL can someone provide me with services such as these? SSH/POP etc? ...